Skip to content

Instantly share code, notes, and snippets.

@62mkv
Last active June 10, 2020 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 62mkv/4e52a906711ce1dc91be024b17553414 to your computer and use it in GitHub Desktop.
Save 62mkv/4e52a906711ce1dc91be024b17553414 to your computer and use it in GitHub Desktop.
Jenkins cookbook
/* using the Jenkins pipeline DSL? We are using */
sshagent([configuration.bitbucketSshCredentialsId]) {
sh "git add ."
sh "git commit -m '$commitComment'
sh "git push $featureBranchName"
}
/* The credential entry is of type "SSH Username with private key" and the corresponding public key is registered for a technical user in Bitbucket. */
/* You could also do something like */
withCredentials([usernamePassword(credentialsId: 'bitbucket.username-password', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh("git config --local user.email 'to-be-replaced-with-something@corp.domain'")
sh("git config --local user.name 'Jenkins'")
sh("git push https://${GIT_USERNAME}:${GIT_PASSWORD}@${scm.getUserRemoteConfigs().get(0).getUrl().replace('https://', '')} --tags")
}
/* (in this case the checkout was done with the Jenkins pipeline scm step before) */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment