Reputation: 2277
I am trying to push to a GitHub repository from Jenkins using
git remote set-url origin [email protected]:$reponame.git
git checkout $branch
git add file
git commit -m "Add file"
git push origin $branch
However I am getting the error:
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.
All the answers I've seen for solving this recommend using the Git Publisher Post Build Step. I am not able to use Git Publisher as I have multiple SCM defined which are defined by the $reponame variable.
I tried looking at the output of git show-ref
and this shows the list of branches that are part of the GitHub repo.
I'm not sure how to solve the above errors, any help on this issue would be greatly appreciated.
UPDATE:
I've been able to successfully push, however the changes are not reflected on the GitHub branch. When I check GitHub the commit is not added to the branch. When I run the job again, the push returns "Everything up to date" implying that the branch that it pushed to already has those changes.
Where is this Git push pushing to? And why are the changes not reflected on the remote GitHub branch?
Upvotes: 5
Views: 3903
Reputation: 3196
I would use Jenkins pipelines or Multibranch which allows you push in your repo without using the GitHub Publisher plugin. You have to create a Jenkinsfile in your repo and create the job follow the documentation. Then you have to options:
SSH as you are doing:
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>'
}
}
HTTPS as another response is suggesting:
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>'
}
}
Upvotes: 2
Reputation: 1329292
As mentioned here, for a bitnami.com environment:
Could you please try to run
source /opt/bitnami/use_jenkins
before configure your Git repo in Jenkins: it will load all the needed env vars that you need.If you're usng a LAMP Stack, the script you're looking for will have the name
/opt/bitnami/use_lamp
Please note that the name of this script has the name
use_APPNAME
.
Depending on the Bitnami Stack you're using the placeholderAPPNAME
will be changed with the name of the app.
Also, double-check the nature of your SSH key (new OPENSSH format or old openssl PEM format)
Upvotes: 2
Reputation: 1001
I had problems while cloning and pushing/pulling with ssh
once so i made it work by using HTTPS where it asks for my github passwords once like you can see in attached image and can use that HTTPS version
URL to remotely add. This will make it work i believe but this isn't actual solution to your problem and SSH
thing should work too. I just gave my alternate solution in case you're stuck in something like urgent work. Thanks Ref Image
Upvotes: 1