Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins SCM Sync Configuration Plugin In Docker Won't Talk to Github

I'm creating an image from the Jenkins Docker image and trying to install the SCM Sync Configuration Plugin. I have a key created that I'm copying to the image that is also copied to the ssh keys for the Github repo. I've tried creating .ssh/ folders in /root as well as /var/jenkins_home. I followed this example and tried adding both of the keys to /etc/ssh/ssh_config. This didn't work. I also tried following another answer (lost the link to it) where you can add a config file to .ssh/ containing something like this:

Host github
    HostName github.com
    User git
    IdentityFile "/var/jenkins_home/.ssh/id_rsa"

This also didn't work. I'm using the credentials plugin + Git plugin and the credentials entry points at the /var/jenkins_home/.ssh/id_rsa file.

Has anyone gotten this plugin or git integration in general working with Jenkins in a Docker image? The errors I get are as follows:

INFO: Creating SCM repository object for url : [email protected]:MY_REPO/scm-sync.git Nov 25, 2014 4:20:30 AM hudson.plugins.scm_sync_configuration.scms.SCM getConfiguredRepository SEVERE: Error creating ScmRepository : No such provider: 'github.com'. Nov 25, 2014 4:20:30 AM jenkins.model.Jenkins WARNING: null java.lang.RuntimeException: Error during ScmSyncConfiguration initialisation ! at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin.init(ScmSyncConfigurationPlugin.java:154) at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationItemListener.onLoaded(ScmSyncConfigurationItemListener.java:24) at jenkins.model.Jenkins.(Jenkins.java:864) at hudson.model.Hudson.(Hudson.java:82) at hudson.model.Hudson.(Hudson.java:78) at hudson.WebAppMain$3.run(WebAppMain.java:222) Caused by: java.lang.NullPointerException at org.apache.maven.scm.manager.AbstractScmManager.getProviderByRepository(AbstractScmManager.java:180) at hudson.plugins.scm_sync_configuration.SCMManipulator.scmConfigurationSettledUp(SCMManipulator.java:60) at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness.initializeRepository(ScmSyncConfigurationBusiness.java:69) at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness.init(ScmSyncConfigurationBusiness.java:64) at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin.init(ScmSyncConfigurationPlugin.java:152) ... 5 more

like image 373
user2868740 Avatar asked Nov 25 '14 22:11

user2868740


Video Answer


1 Answers

Just want to point out that the accepted answer is not the answer to this problem. The SCM sync plugin does not use the credentials plugin. So to be able to access your SCM sync repo, you need to...

  1. Generate an ssh key using ssh-keygen
  2. Go to your github repo settings and add a deploy key. Copy the public key id_rsa.pub generated in previous step.
  3. If you have already setup your SCM sync settings, you will need to unselect your current git repo and then re-add it.

Credit goes to this blog post: https://cburgmer.wordpress.com/2013/01/02/tracking-configuration-changes-in-jenkins/

Note: Inside a docker container the steps are the same. I just add the id_rsa to the container by mounting my host's system .ssh folder as a volume.

e.g. docker run -v /my-user/.ssh:/root/.ssh my-container

like image 149
Ryan Walls Avatar answered Nov 14 '22 22:11

Ryan Walls