Last active
June 10, 2020 07:29
-
-
Save 62mkv/4e52a906711ce1dc91be024b17553414 to your computer and use it in GitHub Desktop.
Jenkins cookbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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