This part of the pipeline provides utility steps for common GIT operations.
mirrorRepository
mirrorRepositoryToRemote
mirrorRepositoryToWorkspace
getFetchOrigin
getPushOrigin
getParentBranch
mirrorRepository(String srcUrl, String targetUrl, List<String> srcCredentialIds = null, List<String> targetCredentialIds = null)
This step is a combination of:
This steps mirrors a GIT repository from srcUrl
to targetUrl
When no
srcCredentialIds
or targetCredentialIds
are provided a auto lookup
of the SSH or http(s) credentials will be performed.
mirrorRepositoryToRemote(String srcRepoPath, GitRepository targetRepo, List<String> targetCredentialIds = null)
Mirrors a local bare cloned repository form $WORKSPACE/$srcRepoPath
to
the targetRepo
. When no targetCredentialIds
are provided a auto
lookup of the SSH or http(s) credentials will be performed.
Mirrors the srcRepo
to the current workspace.
When no srcCredentialIds
are provided a auto lookup of the SSH or http(s) credentials will be performed.
Utility function to get the name of the branch. It will try to retrieve the name in the following order:
- environment variable GIT_BRANCH
- environment variable GIT_LOCAL_BRANCH
- environment variable BRANCH_NAME
- short git commit hash
The result will be stored in the GIT_BRANCH environment variable if the GIT_BRANCH environment variable is not already set.
Utility function to get the fetch origin from a git remote list (git remote -v
). When no remotes
are provided the step will try to
retrieve them by using the internal function _getRemotes
which
basically executes a git remote -v
.
Utility function to get the push origin from a git remote list (git remote -v
). When no remotes
are provided the step will try to
retrieve them by using the internal function _getRemotes
which
basically executes a git remote -v
.
Utility function to get the name of the parent branch. At the moment this is limited to the following logic:
- Use
origin/develop
when branch exists - Use
origin/master
when branch exists - Fallback to
null