Git 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: 'http://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'