Git Integration for Jira Self-Managed (Data Center/Server) Documentation

Contact Support
GitKraken Status  

Class GIJFacade

This is the main facade to be used in ScriptRunner scripts.

Summary

Methods

Type and modifiers Method signature
public Branch createBranch( Integer repoId, String newBranchName, String baseBranchOrTag)
public Repository createIntegration(IntegrationRequest params)
public PullRequest createPullRequest( Integer repoId, String sourceBranchName, String targetBranchName, String title, String issueKey)
public Repository createRepository(Repository params)
public void deleteBranch( Integer repoId, String branchName)
public boolean deleteIntegration( Integer repoId, boolean deleteFiles)
public boolean deleteRepository( Integer repoId, boolean deleteFiles)
public String doReindex( Integer repoId)
public boolean doReindexSynchronized( Integer repoId)
public Collection <Branch> getBranchesForIssue( String issueKey)
public Collection <Branch> getBranchesForIssue( String issueKey, boolean forceAheadBehindCalculation)
public Collection < String > getCommitIssues( Integer repoId, String commitHash)
public Collection <Commit> getCommitsForIssue( String issueKey)
public Collection <Commit> getCommitsForIssue( String issueKey, Boolean showFiles)
public Repository getIntegration( Integer integrationId)
public Collection <Repository> getIntegrations()
public Collection <PullRequest> getPullRequestsForIssue( String issueKey)
public IndexStatusResponse getReindexStatus( String threadId)
public Collection <Repository> getRepositories()
public Collection <Repository> getRepositories( String projectKey)
public Collection <Tag> getTagsForIssue( String issueKey)
public void updateCommitIssueChanges( Integer repoId, String commitHash, IssuesAssociationRequest request)
public Repository updateIntegration( Integer id, IntegrationRequest repositoryWithNewParams)
public Repository updateRepository(Repository newParams)

Methods

createBranch(Integer, String, String)

Creates a branch in the repository.

Branch can be created in a repository which belongs to an integration, otherwise GIJException is thrown.

This is a sync operation.

See script example.

Parameters

  • repoId: the repository id
  • newBranchName: a name of the new branch
  • baseBranchOrTag: a name of a branch or a tag the new branch will be forked from

Returns

branch created

Throws

createIntegration(IntegrationRequest)

Connect to an integration.

This is an async operation.

See script example.

Parameters

  • params: params for the new integration

Throws

createPullRequest(Integer, String, String, String, String)

Creates a new pull request.

This is a sync operation.

See script example.

Parameters

  • repoId: a repository id where the new pull request will be created
  • sourceBranchName: source branch
  • targetBranchName: target branch
  • title: the new pull request title
  • issueKey: issue key, e.g. "TST-234"

Returns

Throws

createRepository(Repository)

Connects a new repository.

This is an async operation.

See script example.
See another script example.

Parameters

  • params: parameters of the new repository including origin, displayName, etc..

Throws

deleteBranch(Integer, String)

Deletes the branch.

Branch can be deleted from a repository which belongs to an integration, otherwise GIJException is thrown.

This is an async operation.

See script example.

Parameters

  • repoId: the repository id
  • branchName: a name of the branch to be deleted

Throws

deleteIntegration(Integer, boolean)

Delete an integration

This is a sync operation.

Parameters

  • repoId: an integration id to be deleted
  • deleteFiles: indicates whether the repositories folders are also deleted from the Jira server. If set to true, the repositories folders is deleted from the Jira server.

Throws

deleteRepository(Integer, boolean)

Deletes the existing repository from the Git Integration for Jira app repository configuration.

This is a sync operation.

See script example.

Parameters

  • repoId: this is the ID of the existing repository. For example, 3.
  • deleteFiles: indicates whether the repository folder is also deleted from the Jira server. If set to true, the repository folder is deleted from the Jira server.

Returns

  • true always

Throws

doReindex(Integer)

Starts the reindex process in a separate thread and returns the result immediately.

Reindex operation can be executed only by admin or a user having access to all repositories.

This is an async operation.

See script example.

Parameters

  • repoId: repository id to be reindexed or null to reindex all

Returns

  • indexer thread ID (UUID), ex. "eafe58fc-d8de-42ff-8815-6fe5860b38d2"

Throws

doReindexSynchronized(Integer)

Reindex a repository and waits for the end of the reindex.

When 10 minutes was not enough to wait for reindexing to finish, then GIJException is thrown.

This is a sync operation.

See script example.

Parameters

  • repoId: repository id to be reindexed or null to reindex all

Returns

Throws

getBranchesForIssue(String)

Returns list of branches associated with the issue.

This is an alias for getBranchesForIssue(issueKey, false),
i.e. a branch ahead and behind won’t be calculated by intent, i.e. they might be undefined.

See script example.

Parameters

  • issueKey: Jira issue key. The issueKey must be valid and existent. Ex.: "TST-234"

Throws

getBranchesForIssue(String, boolean)

Returns list of branches associated with the issue.

When forceAheadBehindCalculation = true, then a branch ahead and behind will be gotten from a cache or calculated.

See script example.

Parameters

  • issueKey: Jira issue key. The issueKey must be valid and existent. Ex.: "TST-234"
  • forceAheadBehindCalculation: whether ahead and behind be calculated by force

Throws

getCommitIssues(Integer, String)

Returns issues which the git commit associated with.

Parameters

  • repoId: a repository id of a commit
  • commitHash: git commit id

Throws

getCommitsForIssue(String)

Returns commits information associated with the issue.

Use getCommitsForIssue(String issueKey, Boolean showFiles) to get commits with files changed.

See script example.

Parameters

  • issueKey: Jira issue key. The issueKey must be valid and existent. Ex.: "TST-234"

Throws

getCommitsForIssue(String, Boolean)

Returns commits information (including files) associated with the issue.

Parameters

  • issueKey: Jira issue key. The issueKey must be valid and existent. Ex.: "TST-234"
  • showFiles: whether an information about files changed in the commit is collected and returned

Throws

getIntegration(Integer)

Returns an integration by id.

Parameters

  • integrationId: the integration id.

Throws

getIntegrations()

Returns integrations connected.

Throws

getPullRequestsForIssue(String)

Returns pull requests associated with the issue.

Parameters

  • issueKey: issue key, e.g. "TST-234"

Throws

getReindexStatus(String)

Use this method to track messages for a particular reindex thread.

See script example.

Parameters

  • threadId: indexer thread ID (UUID), ex. "eafe58fc-d8de-42ff-8815-6fe5860b38d2"

Returns

  • reindex status, messages, errors

Throws

getRepositories()

Returns all repositories connected including disabled repositories and repositories in error status.

See script example.

Throws

getRepositories(String)

Returns repositories visible to users of the project.

So repositories visible globally are returned also. Disabled repositories and repositories in ERROR status are excluded.

See script example.

Parameters

  • projectKey: project key, e.g. "TST"

Throws

getTagsForIssue(String)

Returns tags associated with the issue.

Parameters

  • issueKey: Jira issue key. The issueKey must be valid and existent. Ex.: "TST-234"

Throws

updateCommitIssueChanges(Integer, String, IssuesAssociationRequest)

Changes the commit issues associations.

A change of the commit issues associations in a disabled repository will be ignored.

This is a sync operation.

See script example.

Parameters

  • repoId: a repository id which the git commit belongs to
  • commitHash: a git commit id
  • request: a list of associations changes to be applied

Throws

updateIntegration(Integer, IntegrationRequest)

Updated an integration.

This is a sync operation.

See script example.

Parameters

  • id: integration id to be updated
  • repositoryWithNewParams: new values for parameters to be changed

Returns

  • the integration updated

Throws

updateRepository(Repository)

Updates the existing repository from the given settings.

newParams.id is required. This is the ID of the existing repository. For example, newParams.setId(3).

The updateRepository() API will look for the repository with id = 3 and replaces repository properties with ones setup in newParams.

This is a sync operation.

See script example.

Parameters

  • newParams: new values for parameters to be changed

Returns

  • repository updated

Throws

Have feedback about this article? Did we miss something? Let us know!
On this page