The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.
For a list of other such plugins, see the Pipeline Steps Reference page.
$class: 'GitSCM'
The git plugin provides fundamental git operations for Jenkins projects. It can poll, fetch, checkout, and merge contents of git repositories.
The git plugin provides an SCM implementation to be used with the Pipeline SCM checkout
step. The Pipeline Syntax Snippet Generator guides the user to select git plugin checkout options and provides online help for each of the options.
userRemoteConfigs
${SUPER_PROJECT_URL}/${SUBMODULE}
, rather than relying on information from .gitmodules.url : String
git clone
command.
name : String
origin
, to uniquely identify this repository among other remote repositories. This is the same "name" that you use in your git remote
command. If left empty, Jenkins will generate unique names for you.
You normally want to specify this when you have multiple remote repositories.
refspec : String
git fetch
, which retrieves all the branch heads as remotes/REPOSITORYNAME/BRANCHNAME
. This default behaviour is OK for most cases.
In other words, the default refspec is "+refs/heads/*:refs/remotes/REPOSITORYNAME/*" where REPOSITORYNAME
is the value you specify in the above "name of repository" textbox.
When do you want to modify this value? A good example is when you want to just retrieve one branch. For example, +refs/heads/master:refs/remotes/origin/master
would only retrieve the master branch and nothing else.
The plugin uses a default refspec for its initial fetch, unless the "Advanced Clone Option" is set to honor refspec. This keeps compatibility with previous behavior, and allows the job definition to decide if the refspec should be honored on initial clone.
Multiple refspecs can be entered by separating them with a space character. +refs/heads/master:refs/remotes/origin/master +refs/heads/develop:refs/remotes/origin/develop
retrieves the master branch and the develop branch and nothing else.
See the refspec definition in Git user manual for more details.
credentialsId : String
branches
name : String
Specify the branches if you'd like to track a specific branch in a repository. If left blank, all branches will be examined for changes and built.
The safest way is to use the refs/heads/<branchName>
syntax. This way the expected branch is unambiguous.
If your branch name has a /
in it make sure to use the full reference above. When not presented with a full path the plugin will only use the part of the string right of the last slash. Meaning foo/bar
will actually match bar
.
If you use a wildcard branch specifier, with a slash (e.g. release/
), you'll need to specify the origin repository in the branch names to make sure changes are picked up. So e.g. origin/release/
Possible options:
<branchName>
refs/heads/<branchName>
.master
, feature1
, ...refs/heads/<branchName>
refs/heads/master
, refs/heads/feature1/master
, ...<remoteRepoName>/<branchName>
refs/heads/<branchName>
.origin/master
remotes/<remoteRepoName>/<branchName>
remotes/origin/master
refs/remotes/<remoteRepoName>/<branchName>
refs/remotes/origin/master
<tagName>
refs/tags/<tagName>
instead.git-2.3.0
refs/tags/<tagName>
refs/tags/git-2.3.0
<commitId>
5062ac843f2b947733e6a3b105977056821bd352
, 5062ac84
, ...${ENV_VARIABLE}
${TREEISH}
, refs/tags/${TAGNAME}
, ...<Wildcards>
REPOSITORYNAME/BRANCH
. In addition, BRANCH
is recognized as a shorthand of */BRANCH
, '*' is recognized as a wildcard, and '**' is recognized as wildcard that includes the separator '/'. Therefore, origin/branches*
would match origin/branches-foo
but not origin/branches/foo
, while origin/branches**
would match both origin/branches-foo
and origin/branches/foo
.:<regular expression>
:regexp
. Regular expression syntax in branches to build will only build those branches whose names match the regular expression.:^(?!(origin/prefix)).*
origin
or origin/master
or origin/feature
origin/prefix
or origin/prefix_123
or origin/prefix-abc
:origin/release-\d{8}
origin/release-20150101
origin/release-2015010
or origin/release-201501011
or origin/release-20150101-something
:^(?!origin/master$|origin/develop$).*
origin/branch1
or origin/branch-2
or origin/master123
or origin/develop-123
origin/master
or origin/develop
browser
$class: 'AssemblaWeb'
repoUrl : String
$class: 'BacklogGitRepositoryBrowser'
repoName : String
repoUrl : String
bitbucketServer
repoUrl : String
$class: 'BitbucketWeb'
repoUrl : String
$class: 'CGit'
repoUrl : String
$class: 'FisheyeGitRepositoryBrowser'
repoUrl : String
$class: 'GitBlitRepositoryBrowser'
repoUrl : String
projectName : String
$class: 'GitBucketBrowser'
url : String
$class: 'GitLab'
repoUrl : String
version : String
(optional)
$class: 'GitLabBrowser'
https://gitLab.example.com
then the URL for bob's skunkworks project might be https://gitLab.example.com/bob/skunkworks
.
projectUrl : String
https://gitLab.example.com
then the URL for bob's skunkworks project might be https://gitLab.example.com/bob/skunkworks
$class: 'GitList'
repoUrl : String
$class: 'GitWeb'
repoUrl : String
$class: 'GiteaBrowser'
repoUrl : String
https://gitea.example.com
then the URL for bob's skunkworks project repository might be https://gitea.example.com/bob/skunkworks
$class: 'GithubWeb'
repoUrl : String
$class: 'Gitiles'
repoUrl : String
$class: 'GitoriousWeb'
repoUrl : String
$class: 'GogsGit'
repoUrl : String
$class: 'KilnGit'
repoUrl : String
$class: 'Phabricator'
repoUrl : String
repo : String
$class: 'RedmineWeb'
repoUrl : String
$class: 'RhodeCode'
repoUrl : String
$class: 'ScmManagerGitRepositoryBrowser'
repoUrl : String
$class: 'Stash'
repoUrl : String
$class: 'TFS2013GitRepositoryBrowser'
repoUrl : String
If TFS is also used as the repository server, this can usually be left blank.
$class: 'TracGitRepositoryBrowser'
$class: 'TuleapBrowser'
repositoryUrl : String
$class: 'ViewGitWeb'
repoUrl : String
projectName : String
gitTool : String
Absolute path to the git executable.
This is different from other Jenkins tool definitions. Rather than providing the directory that contains the executable, you must provide the complete path to the executable. Setting '/usr/bin/git
' would be correct, while setting '/usr/bin/
' is not correct.
extensions
Extensions add new behavior or modify existing plugin behavior for different uses. Extensions help users more precisely tune plugin behavior to meet their needs.
Extensions include:
$class: 'AuthorInChangelog'
$class: 'BuildChooserSetting'
This extension point in Jenkins is used by many other plugins to control the job to build specific commits. When you activate those plugins, you may see them installing a custom strategy here.
buildChooser
$class: 'AlternativeBuildChooser'
$class: 'AncestryBuildChooser'
maximumAgeInDays : int
ancestorCommitSha1 : String
$class: 'DefaultBuildChooser'
$class: 'DeflakeGitBuildChooser'
$class: 'GerritTriggerBuildChooser'
$class: 'InverseBuildChooser'
$class: 'BuildSingleRevisionOnly'
$class: 'ChangelogToBranch'
options
compareRemote : String
origin
, that contains the branch you specify below.
compareTarget : String
$class: 'CheckoutOption'
timeout : int
$class: 'CleanBeforeCheckout'
.gitignore
. It also resets all tracked files to their versioned state. This ensures that the workspace is in the same state as if you cloned and checked out in a brand-new empty directory, and ensures that your build is not affected by the files generated by the previous build.
deleteUntrackedNestedRepositories : boolean
(optional)
.git
directories.
$class: 'CleanCheckout'
.gitignore
. It also resets all tracked files to their versioned state. This ensures that the workspace is in the same state as if you cloned and checked out in a brand-new empty directory, and ensures that your build is not affected by the files generated by the previous build.
deleteUntrackedNestedRepositories : boolean
(optional)
.git
directories.
$class: 'CloneOption'
shallow : boolean
noTags : boolean
reference : String
timeout : int
depth : int
(optional)
honorRefspec : boolean
(optional)
$class: 'CodeCommitURLHelper'
credentialId : String
OPTIONAL: Select the credentials to use.
If not specified, defaults to the DefaultAWSCredentialsProviderChain behaviour - *FROM THE JENKINS INSTANCE*
In the latter case, usage of IAM Role Profiles seems not to work, thus relying on environment variables / system properties or the ~/.aws/credentials file, thus not recommended.
repositoryName : String
$class: 'DisableRemotePoll'
$class: 'ExcludeFromChangeSet'
$class: 'ExcludeFromPoll'
$class: 'GitLFSPull'
$class: 'GitSCMChecksExtension'
verboseConsoleLog : boolean
(optional)
$class: 'GitSCMStatusChecksExtension'
name : String
(optional)
skip : boolean
(optional)
skipProgressUpdates : boolean
(optional)
suppressLogs : boolean
(optional)
unstableBuildNeutral : boolean
(optional)
$class: 'GitTagMessageExtension'
useMostRecentTag : boolean
(optional)
$class: 'IgnoreNotifyCommit'
$class: 'LocalBranch'
If selected, and its value is an empty string or "**", then the branch name is computed from the remote branch without the origin. In that case, a remote branch origin/master will be checked out to a local branch named master, and a remote branch origin/develop/new-feature will be checked out to a local branch named develop/newfeature.
Please note that this has not been tested with submodules.
localBranch : String
$class: 'MessageExclusion'
excludedMessage : String
.*\[maven-release-plugin\].*The example above illustrates that if only revisions with "[maven-release-plugin]" message in first comment line have been committed to the SCM a build will not occur. You can create more complex patterns using embedded flag expressions.
(?s).*FOO.*This example will search FOO message in all comment lines.
$class: 'PathRestriction'
includedRegions : String
myapp/src/main/web/.*\.html myapp/src/main/web/.*\.jpeg myapp/src/main/web/.*\.gifThe example above illustrates that a build will only occur, if html/jpeg/gif files have been committed to the SCM. Exclusions take precedence over inclusions, if there is an overlap between included and excluded regions.
excludedRegions : String
myapp/src/main/web/.*\.html myapp/src/main/web/.*\.jpeg myapp/src/main/web/.*\.gifThe example above illustrates that if only html/jpeg/gif files have been committed to the SCM a build will not occur.
$class: 'PerBuildTag'
$class: 'PreBuildMerge'
options
mergeTarget : String
master
.
fastForwardMode
(optional)
FF
, FF_ONLY
, NO_FF
mergeRemote : String
(optional)
origin
, that contains the branch you specify below. If left blank, it'll default to the name of the first repository configured above.
mergeStrategy
(optional)
DEFAULT
, RESOLVE
, RECURSIVE
, OCTOPUS
, OURS
, SUBTREE
, RECURSIVE_THEIRS
pretestedIntegration
gitIntegrationStrategy
accumulated
shortCommitMessage : boolean
(optional)
ffonly
shortCommitMessage : boolean
(optional)
squash
integrationBranch : String
The branch name must match your integration branch name. No trailing slash.
git checkout -B <Branch name> <Repository name>/<Branch name> git merge --squash <Branch matched by git> git commit -C <Branch matched by git>
git checkout -B <Branch name> <Repository name>/<Branch name> git merge -m <commitMsg> <Branch matched by git> --no-ff
Changes are only ever pushed when the build results is SUCCESS
git push <Repository name> <Branch name>
repoName : String
The repository name. In git the repository is always the name of the remote. So if you have specified a repository name in your Git configuration. You need to specify the exact same name here, otherwise no integration will be performed. We do the merge based on this.
No trailing slash on repository name.
Remember to specify this when working with NAMED repositories in Git
$class: 'PruneStaleBranch'
pruneTags
pruneTags : boolean
$class: 'RelativeTargetDirectory'
relativeTargetDir : String
This extension should not be used in Jenkins Pipeline (either declarative or scripted). Jenkins Pipeline already provides standard techniques for checkout to a subdirectory. Use ws and dir in Jenkins Pipeline rather than this extension.
$class: 'ScmName'
Unique name for this SCM. Needed when using Git within the Multi SCM plugin.
name : String
$class: 'SparseCheckoutPaths'
Specify the paths that you'd like to sparse checkout. This may be used for saving space (Think about a reference repository). Be sure to use a recent version of Git, at least above 1.7.10
sparseCheckoutPaths
path : String
$class: 'SubmoduleOption'
disableSubmodules : boolean
recursiveSubmodules : boolean
trackingSubmodules : boolean
reference : String
git init --bare git remote add SubProject1 https://gitrepo.com/subproject1 git remote add SubProject2 https://gitrepo.com/subproject2 git fetch --all
timeout : int
parentCredentials : boolean
depth : int
(optional)
shallow : boolean
(optional)
threads : int
(optional)
$class: 'UserExclusion'
excludedUsers : String
auto_build_userThe example above illustrates that if only revisions by "auto_build_user" have been committed to the SCM a build will not occur.
$class: 'UserIdentity'
name : String
If given, "GIT_COMMITTER_NAME=[this]" and "GIT_AUTHOR_NAME=[this]" are set for builds. This overrides whatever is in the global settings.
email : String
If given, "GIT_COMMITTER_EMAIL=[this]" and "GIT_AUTHOR_EMAIL=[this]" are set for builds. This overrides whatever is in the global settings.
$class: 'WipeWorkspace'
doGenerateSubmoduleConfigurations : boolean
(optional)
Removed facility that was intended to test combinations of git submodule versions. Removed in git plugin 4.6.0. Ignores the user provided value and always uses false
as its value.
submoduleCfg
(optional)
Removed facility that was intended to test combinations of git submodule versions. Removed in git plugin 4.6.0. Ignores the user provided value(s) and always uses empty values.
submoduleName : String
Removed in git plugin 4.6.0.
branches : Array / List of String
Removed in git plugin 4.6.0.
Please submit your feedback about this page through this quick form.
Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?
See existing feedback here.