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.
git
: GitGit step. It performs a clone from the specified repository.
Use the Pipeline Syntax Snippet Generator to generate a sample pipeline script for the git step. More advanced checkout operations require the checkout
step rather than the git
step. Examples of the git
step include:
The git
step is a simplified shorthand for a subset of the more powerful checkout
step:
checkout([$class: 'GitSCM', branches: [[name: '*/master']], userRemoteConfigs: [[url: 'https://git-server/user/repository.git']]])
NOTE: The checkout
step is the preferred SCM checkout method. It provides significantly more functionality than the git
step.
Use the Pipeline Syntax Snippet Generator to generate a sample pipeline script for the checkout step.
The checkout
step can be used in many cases where the git
step cannot be used. Refer to the git plugin documentation for detailed descriptions of options available to the checkout step. For example, the git
step does not support:
Checkout from the git plugin source repository using https protocol, no credentials, and the master branch.
The Pipeline Syntax Snippet Generator generates this example:
git 'https://github.com/jenkinsci/git-plugin'Example: Git step with https and a specific branch
Checkout from the Jenkins source repository using https protocol, no credentials, and a specific branch (stable-2.204). Note that this must be a local branch name like 'master' or 'develop'.
Branch names that are not supported by the git
step
Remote branch names, SHA-1 hashes, and tag names are supported by the general purpose checkout
step.
The Pipeline Syntax Snippet Generator generates this example:
git branch: 'stable-2.204', url: 'https://github.com/jenkinsci/jenkins.git'Example: Git step with ssh and a private key credential
Checkout from the git client plugin source repository using ssh protocol, private key credentials, and the master branch. The credential must be a private key credential if the remote git repository is accessed with the ssh protocol. The credential must be a username / password credential if the remote git repository is accessed with http or https protocol.
The Pipeline Syntax Snippet Generator generates this example:
git credentialsId: 'my-private-key-credential-id', url: 'git@github.com:jenkinsci/git-client-plugin.git'Example: Git step with https and changelog disabled
Checkout from the Jenkins source repository using https protocol, no credentials, the master branch, and changelog calculation disabled. If changelog is false
, then the changelog will not be computed for this job. If changelog is true
or is not set, then the changelog will be computed. See the workflow scm step documentation for more changelog details.
The Pipeline Syntax Snippet Generator generates this example:
git changelog: false, url: 'https://github.com/jenkinsci/credentials-plugin.git'Example: Git step with https protocol and polling disabled
Checkout from the Jenkins platform labeler repository using https protocol, no credentials, the master branch, and no polling for changes. If poll is false
, then the remote repository will not be polled for changes. If poll is true
or is not set, then the remote repository will be polled for changes. See the workflow scm step documentation for more polling details.
The Pipeline Syntax Snippet Generator generates this example:
git poll: false, url: 'https://github.com/jenkinsci/platformlabeler-plugin.git'Argument Descriptions
url : String
URL of the repository to be checked out in the workspace. Required parameter.
Repository URL's should follow the git URL guidelines. Git steps to access a secured repository should provide a Jenkins credential with the credentialsId
argument rather than embedding credentials in the URL. Credentials embedded in a repository URL may be visible in console logs or in other log files.
branch : String
(optional)
Branch to be checked out in the workspace. Default is 'master
'.
Note that this must be a local branch name like 'master' or 'develop'. Remote branch names like 'origin/master' and 'origin/develop' are not supported as the branch argument. Tag names are not supported as the branch argument. SHA-1 hashes are not supported as the branch argument. Remote branch names, tag names, and SHA-1 hashes are supported by the general purpose checkout
step.
changelog : boolean
(optional)
Compute changelog for this job. Default is 'true
'.
If changelog
is false, then the changelog will not be computed for this job. If changelog
is true or is not set, then the changelog will be computed.
credentialsId : String
(optional)
Identifier of the credential used to access the remote git repository. Default is '<empty>'.
The credential must be a private key credential if the remote git repository is accessed with the ssh protocol. The credential must be a username / password credential if the remote git repository is accessed with http or https protocol.
poll : boolean
(optional)
Poll remote repository for changes. Default is 'true
'.
If poll
is false, then the remote repository will not be polled for changes. If poll
is true or is not set, then the remote repository will be polled for changes.
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.