Jenkins on Openshift cannot clone repo Jenkins on Openshift cannot clone repo jenkins jenkins

Jenkins on Openshift cannot clone repo


You can try and follow "Building a project hosted on Github using an Openshift Jenkins instance " from Ramzi MaĆ¢lej.

Make sure Openshift doesn't grant write permission on several folders on a Jenkins instance such as: .ssh, .m2. (or ssh would not work anyway, because of right on folders "too permissive")
That alone could be the source of your problems, but if that is not enough, read on.

Then:

rhc ssh buildservermkdir app-root/data/git-sshssh-keygen -t rsa -b 4096 -C "youremail@yourdomain.com" -f $OPENSHIFT_DATA_DIR/git-ssh/id_rsa

Deploy your $OPENSHIFT_DATA_DIR/git-ssh/id_rsa.pub to your GitHub account

Create a script ssh-wrapper.sh that does the following:

#!/bin/bashID_RSA="$OPENSHIFT_DATA_DIR/git-ssh/id_rsa"KNOWN_HOSTS="$OPENSHIFT_DATA_DIR/git-ssh/known_hosts"ssh -o UserKnownHostsFile=$KNOWN_HOSTS -i $ID_RSA $1 $2

Don't forget to make it executable: chmod +x ssh-wrapper.sh

Test it:

 ./ssh-wrapper.sh -T git@github.comHi Jenkins! You've successfully authenticated, but GitHub does not provide shell access.

Finally, configure Jenkins:

go to Manage Jenkins > Configure System > Global Properties and create a new environment variable called GIT_SSH that refers to the location where you created your wrapper.


SSH into your Jenkins app and use the public key contained in $OPENSHIFT_DATA_DIR/.ssh/jenkins_id_rsa.pub as your Github/Gitlab/Bitbucket deploy key.