jenkinsgithubjenkins-github-plugin

pull github committed code auto to server using jenkins


I have just started using jenkins. i have setup jenkins on my server and created item which intimate when someone commit changes on github . but the problem is its only showing me the changes commit. but not pulling changes to my code on server auto when code committed to git repository.

Please help me to get one.

Yes i have done with webhook. everything is working fine. i am getting the notification someone commit code to github but the problem is code is not changing accordingly to my server.

example: i have one repo and someone added one file test.html on git repo. so i'll get the notification using jenkins and its auto build working. but the problem is test.html not auto adding to my code on server. like auto pulling code. i need to take pull form server. then it will add changes to my server.i want to automate this.

Jenkins conf screenshots:

https://prnt.sc/pd6y6m  
https://prnt.sc/pd6yat  
https://prnt.sc/pd6ydi

Solution

  • According to the 3rd picture I think that you would like to have your code in the directory /home/tomcat/. You will find your code at /var/lib/jenkins/jobs/<jobname>/workspace/. That is the directory where your code will be pulled. The command to switch the directory will be executed after pulling the repository.

    To move all the files from your repository to a different directory you could use a move statement in your shell script:

    mv /var/lib/jenkins/jobs/<jobname>/workspace/* /home/tomcat/