AKS
AKS

Reputation: 17326

SCM Sync configuration plugin - Jenkins GIT prompt issue

Jenkins version: 1.642.3

SCM Sync Configuration Plugin version: 0.0.10

I created a private repository for storing Jenkins job's configuration (which is the git url that I'll use in Jenkins's Global configuration page while configuring this plugin). As I created a private repo (which is not open to anyone), I had to add any collaborators (jenkins service user which is running Jenkins master process on the Jenkins master server). If in your case, it's different, look for user name user.name under Manage Jenkins > System Information for the user which is running Jenkins process otherwise, you'll get an error that OS user doesn't have access to the repository or permission denied (Public Key). One other solution is to generate ssh key (ssh-keygen -t rsa and once the Key files are generated, putting the .pub public key in your Github user's SSH settings section: https://git.instance.yourcomany.com/settings/ssh).

One Important Note: While configuring the logger, if you accidentally pick hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin as it shows up in the list of available options (vs using the correct value which is hudson.plugins.scm_sync_configuration) then logger will NOT log anything. enter image description here The above setting will make this plugin not log anything in the logger, so make sure you set the logger to the correct value.

AFTER this, everything is looking good so far in Jenkins main Global configuration page for configuring this plugin (no errors there) and at the right bottom of Jenkins home page, I can see "SCM Sync status : Last operation @ Tue Jul 25 11:55:43 PDT 2017"

I created a dummy job (and did echo something && sleep 60 in the build step) and tried to make few changes to this build step for changing the sleep time to some random values.

My expection was I should have been prompted for making any changes to the Jenkins job and that Jenkins job should be checked-in in the given GIT repo (as now the pub key for jenkins user is all set). PS: I'm succesfully able to clone from this repo in another test jenkins job (running on master node) + I'm also able to successfully git clone + git push to this repo from Jenkins master server (just added README.md myself as jenkins user). In the logger's log, I can see:

Jul 25, 2017 11:53:37 AM FINE hudson.plugins.scm_sync_configuration.SCMManipulator checkinFiles
Checking in SCM files ...
Jul 25, 2017 11:53:37 AM FINE hudson.plugins.scm_sync_configuration.SCMManipulator checkinFiles
Checked in SCM files !
Jul 25, 2017 11:53:37 AM FINEST hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness processCommitsQueue
Commit Commit hudson.plugins.scm_sync_configuration.model.Commit@5d951ea : 
  Author : asangal
  Comment : asangal: Jenkins configuration files updated

Change performed by asangal

  Changeset : 
    A hudson.scm.SubversionSCM.xml
    A hudson.plugins.ansicolor.AnsiColorBuildWrapper.xml
    A hudson.plugins.git.GitTool.xml
    A hudson.scm.CVSSCM.xml
    A hudson.tasks.Mailer.xml
    A hudson.plugins.gradle.Gradle.xml
    A hudson.tasks.Ant.xml
    A hudson.plugins.git.GitSCM.xml
    A hudson.plugins.groovy.Groovy.xml
    A jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin.xml
    A hudson.triggers.SCMTrigger.xml
    A hudson.maven.MavenModuleSet.xml
    A jenkins.mvn.GlobalMavenConfig.xml
    A jenkins.model.ArtifactManagerConfiguration.xml
    A hudson.tasks.Shell.xml
    A scm-sync-configuration.xml
    A hudson.plugins.copyartifact.TriggeredBuildSelector.xml
    A config.xml
    A hudson.tasks.Maven.xml
    A jenkins.metrics.api.MetricsAccessKey.xml
    A hudson.plugins.timestamper.TimestamperConfig.xml
    A jenkins.model.JenkinsLocationConfiguration.xml
    A hudson.plugins.build_timeout.operations.BuildStepOperation.xml
    A hudson.plugins.mercurial.MercurialInstallation.xml
    A hudson.plugins.emailext.ExtendedEmailPublisher.xml
    A hudson.plugins.throttleconcurrents.ThrottleJobProperty.xml

 pushed to SCM !
Jul 25, 2017 12:49:48 PM FINEST hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness queueChangeSet
Queuing commit Commit hudson.plugins.scm_sync_configuration.model.Commit@5511458b : 
  Author : asangal
  Comment : asangal: Job [dummy_job] configuration updated

Change performed by asangal

  Changeset : 
    A jobs/dummy_job/config.xml

 to SCM ...
Jul 25, 2017 12:49:48 PM FINEST hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness processCommitsQueue
Processing commit : Commit hudson.plugins.scm_sync_configuration.model.Commit@5511458b : 
  Author : asangal
  Comment : asangal: Job [dummy_job] configuration updated

Change performed by asangal

  Changeset : 
    A jobs/dummy_job/config.xml


Jul 25, 2017 12:49:48 PM FINE hudson.plugins.scm_sync_configuration.SCMManipulator checkinFiles
Checking in SCM files ...
Jul 25, 2017 12:49:48 PM FINE hudson.plugins.scm_sync_configuration.SCMManipulator checkinFiles
Checked in SCM files !
Jul 25, 2017 12:49:48 PM FINEST hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness processCommitsQueue
Commit Commit hudson.plugins.scm_sync_configuration.model.Commit@5511458b : 
  Author : asangal
  Comment : asangal: Job [dummy_job] configuration updated

Change performed by asangal

  Changeset : 
    A jobs/dummy_job/config.xml

 pushed to SCM !

Questions:

1) Why I didn't get prompted when I made changes to Jenkins job?

2) Why I'm not seeing any commits (which the logger is showing successfully checked-in / pushed, in the log) to the my target git repo? My github repo just shows README.md file so far.

3) Where exactly did this plugin CHECKED-IN the files and pushed?

Upvotes: 0

Views: 1926

Answers (2)

AKS
AKS

Reputation: 17326

Resolution / steps followed to properly check and implement this plugin:

Make sure:

1) Before you setup SCM Sync configuration, you have a repository / project created in Git

2) Find the user (which is running jenkins process). Usually it's jenkins user. If required, work with your system team and have them create a service/ldap user account named jenkins so that you can add jenkins user (or whatever user running the jenkins process) in Git/Github as one of the Collaborator with write access. If that's not possible, then go to Jenkins Master server and sudo su - jenkins and make sure you create (ssh keys). Once created, grab the public key and upload the key to Github repositories under Settings > Deploy Keys.

3) For this user, create a ~/.gitconfig file and put the following contents in this file.

user]
    name = enter_theuserid
    email = [email protected]
[core]
    editor = vim
[color]
    ui = auto

4) Now configure SCM Sync plugin in Jenkins global settings configuration (As per the Plugin's documentation). As soon as you provide the git@git..:org/your-repo.git, you'll notice that it'll not error out by saying the OS user running Jenkins is not able to do anything.

5) Create a new LOGGER (make sure Logger value is: hudson.plugins.scm_sync_configuration)

6) Go to Jenkins master server under: $JENKINS_HOME/scm-sync-configuration/checkoutConfiguration folder. Look for .git folder. If that's not present, that means, SCM Sync plugin didn't perform any checkout. To find if there are any issues with this plugin able to check out the Git repo, you can create another new logger where the Logger value should be hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin from the list box available options.

7) If you didn't find .git in bullet 5th folder, then remove checkoutConfiguration folder (leaf folder only) and in Jenkins Global configuration for SCM Sync plugin, change version control from Git to None (radio button), save it. Then go back and select Git (radio button) and provide git@git...:org/repo-name.git URL again and Save.

8) Keep an eye on the logs. This time if the user (running the Jenkins process) is listed in Git repository as a valid collaborator with WRITE access OR if it's SSH pub key is uploaded to Github repository, then it'll successfully CHECKOUT the repository to $JENKINS_HOME/scm-sync-configuration/checkoutConfiguration folder. Inside this folder, you'll see all valid .git/* files.

9) For testing purpose, you can make a small change in a file under $JENKINS_HOME/scm-sync-configuration/checkoutConfiguration folder, and run git add thatfilename; git commit -m "test change" $_; git pull && git push

10) If bullet 9 succeeds, at this point you'll have a working SCM Sync plugin where when you make a change to a Jenkins job, as soon as you press SAVE button, it'll first PROMPT via a popup modal window and request the user to enter some comment.

Upvotes: 1

Suresh
Suresh

Reputation: 750

Goto Jenkins -> Manage Jenkins -> Configure System. Under SCM Sync Configuration section look for "Never bother me with commit messages" configuration.

If you want Jenkins to prompt for commit messages when Job has been modified, Uncheck the option "Never bother me with commit messages".

Upvotes: 0

Related Questions