Jenskins on Openshift can't clone repo

I am new to both Jenkins and Openshift, so I got a little attached.

I installed Jenkins and pointed it to my github repo, but it cannot clone it, because I cannot find my git credentials anywhere, and when I ssh in the jenkins box, I cannot access ~ / .ssh to create new keys or find them there. Another issue may be that my git repository is private.

I tried Google but couldn't find anything. How to allow Jenkins access to my private repo?

?

edit: ok I found in management and then set up a place for username and email. then I used ssh'd and used ssh-keygen to create the ssh key in .openshift_ssh and added it to github, first as a regular ssh key, then as a deployment key, and then the same in app-root / data /. ssh but still nothing

+6
source share
2 answers

You can try " Building a project hosted on Github using an instance of Openshift Jenkins " by Ramzi MaΓ’lej.

Ensure that Openshift does not provide write permissions in multiple folders on the Jenkins instance, for example: .ssh , .m2 . (or ssh will not work anyway, because of the permissions on the folders are "too permissive")
This in itself may be the source of your problems, but if that is not enough, read on.

Then:

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

Expand $OPENSHIFT_DATA_DIR/git-ssh/id_rsa.pub into your GitHub account

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

 #!/bin/bash ID_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 

Remember to make it doable: chmod +x ssh-wrapper.sh

Check it:

  ./ssh-wrapper.sh -T git@github.com Hi 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 place where you created your wrapper.

+5
source

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

0
source

All Articles