This is the main facade to be used in ScriptRunner scripts.
Summary
Methods
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 idnewBranchName
: a name of the new branchbaseBranchOrTag
: 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 createdsourceBranchName
: source branchtargetBranchName
: target branchtitle
: the new pull request titleissueKey
: 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
- org.eclipse.jgit.api.errors.GitAPIException
- IOException
- GIJException
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 idbranchName
: 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 deleteddeleteFiles
: 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
- IOException
- GIJException
- com.atlassian.jira.issue.index.IndexException
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
- IOException
- GIJException
- com.atlassian.jira.issue.index.IndexException
getCommitIssues(Integer, String)
Returns issues which the git commit associated with.
Parameters
repoId
: a repository id of a commitcommitHash
: git commit id
Throws
- IOException
- GIJException
- com.atlassian.jira.issue.index.IndexException
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
- IOException
- GIJException
- com.atlassian.jira.issue.index.IndexException
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
- IOException
- GIJException
- com.atlassian.jira.issue.index.IndexException
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 tocommitHash
: a git commit idrequest
: 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 updatedrepositoryWithNewParams
: 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