我正试图从Jenkins推送到GitHub存储库
git remote set-url origin [email protected]:$reponame.git
git checkout $branch
git add file
git commit -m "Add file"
git push origin $branch
但是我收到错误:
ssh: /opt/bitnami/common/lib/libcrypto.so.1.0.0: no version information available (required by ssh)
ssh: /opt/bitnami/common/lib/libcrypto.so.1.0.0: no version information available (required by ssh)
Host key verification failed.
我见过的解决这个问题的所有答案都建议使用Git Publisher Post Build Step。我无法使用Git Publisher,因为我有多个SCM定义,由$ reponame变量定义。
我试着查看git show-ref
的输出,这显示了属于GitHub仓库的分支列表。
我不确定如何解决上述错误,对此问题的任何帮助将不胜感激。
更新:我已经能够成功推送,但更改不会反映在GitHub分支上。当我检查GitHub时,提交没有添加到分支。当我再次运行作业时,推送返回“Everything up the date”,意味着它推送的分支已经有了这些更改。 这个Git推动到哪里去了?为什么这些变化没有反映在远程GitHub分支上?
我会使用Jenkins pipelines或Multibranch,它允许你在不使用GitHub Publisher插件的情况下推送你的仓库。你必须在你的仓库中创建一个Jenkinsfile并按照文档创建工作。然后你必须选择:
stage('Preparation') {
// Get some code from the branch sending the webhook in GitHub
git 'your git repo'
}
stage('Build') {
// Do some stuff here
}
stage('Push') {
// Commit and push with ssh credentials
sshagent (credentials: ['your credentials']) {
sh "git commit -am 'Commit message'"
sh 'git push origin HEAD:<yourbranch>'
}
}
stage('Preparation') {
// Get some code from the branch sending the webhook in GitHub
git 'your https repo'
}
stage('Build') {
// Do some stuff here
}
stage('Push') {
// Commit and push with ssh credentials
withCredentials(
[string(credentialsId: 'git-email', variable: 'GIT_COMMITTER_EMAIL'),
string(credentialsId: 'git-account', variable: 'GIT_COMMITTER_ACCOUNT'),
string(credentialsId: 'git-name', variable: 'GIT_COMMITTER_NAME'),
string(credentialsId: 'github-token', variable: 'GITHUB_API_TOKEN')]) {
// Configure the user
sh 'git config user.email "${GIT_COMMITTER_EMAIL}"'
sh 'git config user.name "${GIT_COMMITTER_NAME}"'
sh "git remote rm origin"
sh "git remote add origin https://${GIT_COMMITTER_ACCOUNT}:${GITHUB_API_TOKEN}@yourrepo.git > /dev/null 2>&1"
sh "git commit -am 'Commit message'"
sh 'git push origin HEAD:<yourbranch>'
}
}
作为mentioned here,对于bitnami.com环境:
你可以尝试在Jenkins中配置你的Git仓库之前运行
source /opt/bitnami/use_jenkins
:它将加载你需要的所有所需的env变量。如果您正在使用LAMP堆栈,那么您正在寻找的脚本将具有名称
/opt/bitnami/use_lamp
请注意,此脚本的名称为
use_APPNAME
。 根据您使用占位符的Bitnami堆栈,APPNAME
将随应用程序的名称进行更改。
另外,仔细检查SSH密钥的性质(new OPENSSH format or old openssl PEM format)
我在使用ssh
进行克隆和推/拉时遇到了问题所以我通过使用HTTPS使其工作,它会像我们在附加图像中看到的那样请求我的github密码,并且可以使用该HTTPS version
URL进行远程添加。这将使它工作,我相信,但这不是你的问题的实际解决方案和SSH
事情也应该工作。我刚给出了我的替代解决方案,以防你遇到紧急工作。谢谢Ref Image