Jenkins and github
I have a jenkins server with the github plugin to trigger every time a change is made to the repo.
I have the private key and the public key loaded into the github repo.
The job is configured as:
Repository URL email@example.com:xxx/repo.git
I didn’t enter the URL in the top part of the job.
One of the tasks I have Jenkins do is:
cd /var/www/html/ && git pull origin master
But whenever I make a change to the repo it is not being triggered and I don’t know why.
When I run the build manually I get:
[Unit_Test] $ /bin/sh -xe /tmp/hudson1951363618156731736.sh
+ cd /var/www/html/
+ git pull origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Build step ‘Execute shell’ marked build as failure
Email was triggered for: Failure – Any
Sending email for trigger: Failure – Any
Sending email to: firstname.lastname@example.org
2 Solutions collect form web for “Jenkins and github”
Don’t just use Jenkins as a shell script executor:
- Use the Git plugin and configure it correctly. With this you should be able to pull code
- Use the GitHub plugin and check the
Build when a change is pushed to GitHuband add the hook to your repo on GitHub so Jenkins gets notified whenever a change is pushed
- Under the point
Execute shelland prepare the environment for the actual build
Had to add polling with * * * * * to get it to work.