Reputation: 774
I am trying to automate creating and pushing the git branches and tags to the remote using Jenkins pipeline but unable to do so. Below are the steps that I tried:
Jenkins script:
stage("Create New Release Branch") {
sh 'chmod 777 -R ./jenkins-scripts'
sh './jenkins-scripts/lock-branch.sh'
}
shell script(lock-branch.sh
):
#!/usr/bin/env bash
git branch "release/R.$(date +%Y/%m/5d)"
sleep 5
git push -u origin "release/R.$(date +%Y/%m/%d)"
sleep 10
release_tag="release/R.$(date +%Y/%m/%d)"
echo $release_tag
sleep 5
git tag -a $release_tag
sleep 10
git push origin tag $release_tag
Jenkins logs error:
[Pipeline] stage
[Pipeline] { (Create New Release Branch)
[Pipeline] sh
+ chmod 777 -R ./jenkins-scripts
[Pipeline] sh
+ ./jenkins-scripts/lock-branch.sh
fatal: could not read Username for 'https://github.company.com': No such device or address
release/R.2025/01/31
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'unknown@4b1399564e64.(none)')
error: src refspec refs/tags/release/R.2025/01/31 does not match any.
error: failed to push some refs to 'https://github.company.com/some-org/some-repo.git'
[Pipeline] }
Upvotes: 0
Views: 40
Reputation: 1645
Git told you what is wrong, you haven't setup your user.email or user.name. And it told you how to fix that. I'm guessing you usually run git under your own user id, but jenkins is running as a different user id that hasn't been setup. Login as jenkins' user on the machine running jenkins, get it to work from the command line as that user, then you should be in a better position to have it work under jenkins.
Upvotes: 0