Collaboration Properties

Started by blakesha, June 07, 2024, 01:56:56 AM

Previous topic - Next topic


Hi Team

Is there any way to get at the collaboration properties of the model from script. Specifically, the current branch details?

Phil Beauvoir


jArchi is not linked to other Archi plug-ins such as coArchi and so there is no API that exposes coArchi's methods. However, you could either add the JGit library that coArchi uses ( to the class path and use that or read the contents of the "<repo_path>/.git/HEAD" file to access the current branch.

Here's some example code:

var imports = new JavaImporter(org.eclipse.jgit.api,, java.nio.file);
with(imports) {
    // Path to the git repository (on Windows)
    const repoPath = new File("C:/Users/user-name/Documents/Archi/model-repository/repo");

    // Method #1 - using JGit to access the repository

    // Path to the lib folder containing JGit jar files (on Windows)
    const libPath =  new File("C:/Users/user-name/AppData/Roaming/Archi/dropins/org.archicontribs.modelrepository_0.9.2.202311181027/lib");
    // Add JGit jars to the class path
    libPath.listFiles().forEach(jarFile => {

    // Open the repository using JGit
    const git =;

    // Print the current branch
    // Close the JGit repository

    // Method #2 - read the "HEAD" file in the .git folder of the repo

    const path = new File(repoPath, ".git/HEAD").toPath();
    const branch = Files.readString(path);

If all you want to do is get the name of the current branch, the second method is far simpler. Note that access to JGit and calling its methods is done at your own peril, and the jar file paths will be different for each coArchi version.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.