SCM sync not working
I want to sync my Jenkins backup data with git repo. so i follow following steps:
1- I have set git global credential into jenkins GIT option under configuration.
2- Installed scm sync plugin and put configuration parameter in jenkins scm sync configuration tab repo url firstname.lastname@example.org:username/jenkins_config.git
3 - save
But i am getting below error:
"Error while adding SCM file : fatal: Not a git repository (or any of the parent directories): .git"
I just ran into this problem. As a preface: this plugin is generally really frustrating to do anything with because of how opaque and unhelpful the error messages are. That said, what the issue actually meant in my case is one of a few things I had to do to correct the issue:
- That the access group on Github I had configured for my backup-repo did not have write access.
- At one point the repo was misspelled in the config by me (git@github/ instead of git@github:).
- Finally, this plugin seems to like restarts quite a bit. After changing a setting, run a Jenkins restart to get new error messages that better assist in diagnosing the problem.
Aside from those, the system log info in hudson.plugins.scm_sync_configuration is particularly helpful, and frequently more telling than the general page errors.
This sequence worked for me with Git:
- Install the SCM Sync plugin
- Enter the Git Repository URL in Jenkins > Configuration > SCM Sync configuration
- Restart Jenkins. At this point the SCM Sync plugin would only commit files after I changed them. All the other unmodified files were not committed to Git.
- Remove the Git Repository URL in Jenkins > Configuration > SCM Sync configuration. Click Save.
- Put back the Git Repository URL in Jenkins > Configuration > SCM Sync configuration. Click Save.
In a scratch directory, verify that all files are present using:
git clone git@email@example.com:username/jenkins_config.git cd jenkins_config find .
Hopefully find will print all your config.xml files.
I recorded the exact steps I took above. I do not know if they are all absolutely necessary (particularly steps 2 and 4). The strategy is to repeatedly restart and remove/add the Git Repository URL until it works.