Parvez Alam
Parvez Alam

Reputation: 398

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 [email protected]: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"

Upvotes: 5

Views: 5401

Answers (2)

John McGehee
John McGehee

Reputation: 10329

This sequence worked for me with Git:

  1. Install the SCM Sync plugin
  2. Enter the Git Repository URL in Jenkins > Configuration > SCM Sync configuration
  3. 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.
  4. Remove the Git Repository URL in Jenkins > Configuration > SCM Sync configuration. Click Save.
  5. Put back the Git Repository URL in Jenkins > Configuration > SCM Sync configuration. Click Save.
  6. In a scratch directory, verify that all files are present using:

    git clone git@[email protected]: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.

Upvotes: 3

Eli
Eli

Reputation: 38949

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:

  1. That the access group on Github I had configured for my backup-repo did not have write access.
  2. At one point the repo was misspelled in the config by me (git@github/ instead of git@github:).
  3. 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.

Upvotes: 3

Related Questions