Skip to content

Instantly share code, notes, and snippets.

@domdorn

domdorn/Jenkinsfile Secret

Created Mar 12, 2021
Embed
What would you like to do?
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