Hi I want to push in Jenkins pipeline script.
I registered git id/pw in Jenkins credentials.
I succeeded git clone. This is git clone script
git branch: "develop", credentialsId: "mygitid", url: "mygiturl"
Now I want to commit & push.. but I don't know how to do this.. Anyone have idea?
CodePudding user response:
It is possible to push from a Jenkins pipeline, using the Credentials Binding pugin
stage('git push') {
steps {
withCredentials([
gitUsernamePassword(credentialsId: 'mygitid', gitToolName: 'Default')
]) {
sh '''
# modify some files
git add .
git commit -m "register work"
git push
'''
}
}
}
This assumes you remain on the default cloned branch (usually 'main
')