Skip to content

Instantly share code, notes, and snippets.

@domdorn
Created March 12, 2021 22:53
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 domdorn/5f8a8d6047f936653922091db453d4d0 to your computer and use it in GitHub Desktop.
Save domdorn/5f8a8d6047f936653922091db453d4d0 to your computer and use it in GitHub Desktop.
Jenkins + HTTPS Git + .netrc
environment {
JENKINS_GIT = credentials('jenkins_svc-git.credentials')
}
….
stage('Deploy to TEST') {
when {
branch 'master'
expression {
input message: 'Deploy to test system?'
return true
}
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
script {
sh "git config --local user.name 'Jenkins CI'"
sh "git config --local user.email 'jenkins@acme.com'"
sh "git remote set-url origin https://srv.acme.com/bitbucket/scm/proj/repo.git"
sh 'echo "machine srv.acme.com\nlogin ${JENKINS_GIT_USR}\npassword ${JENKINS_GIT_PSW}" > .netrc; chmod 600 ./.netrc; '
sh "HOME=`pwd` git push --tags"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment