我正在尝试在jenkins管道(Jenkinsfile)的成功块中添加git push标签
post {
failure {
...
}
success {
script {
sshagent (credentials: ['jenkins']) {
sh """
if ${BUILD} ; then
git config user.name 'Jenkins'
git config user.email '########@users.noreply.github.com'
git tag -a twist_v${BUILD_VERSION}_#${BUILD_NUMBER} -m ${JENKINS_TAG_MESSAGE}
git push --tags
fi
"""
}
}
}
cleanup {
cleanWs()
}
}
但是出现以下错误:
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-axSxDPfiJVd4/agent.28367
SSH_AGENT_PID=28369
Running ssh-add (command line suppressed)
Identity added: /home/jenkins/jenkins_slave/workspace/Firmware@tmp/private_key_6077107140528635470.key (/home/jenkins/jenkins_slave/workspace/Firmware@tmp/private_key_6077107140528635470.key)
[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
+ true
+ true
+ git config user.name Jenkins
+ git config user.email ########@users.noreply.github.com
+ git tag -a twist_v1.1.1_328 -m By Jenkins
+ git push --tags
fatal: could not read Username for 'https://github.com': No such device or address
[Pipeline] }
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 28369 killed;
[ssh-agent] Stopped.
[Pipeline] // sshagent
此jenkins-slave在Ubuntu上运行。