Continuous Integration with Jenkins, after code is pushed to repository from Git command/ GUI:
.git/hooks
folder.The hooks
folder contains the few files. Check for the "post-commit". If not present, create a file, "post-commit" without a file extension:
C:\work\test\\.git\hooks\post-commit
Edit the "post-commit" file with the below command. Make sure it is present in your local source code hooks folder.
curl -u userName:apiToken -X POST http://localhost:8080/jenkins/job/jobName/build?token=apiToken
Example:
curl -u admin:f1c55b3a07bb2b69b9dd549e96898384 -X POST http://localhost:8080/jenkins/job/Gitcommittest/build?token=f1c55b3a07bb2b69b9dd549e96898384
5.
userName
: Jenkins user name
jobName
: Job name of the build
apiToken
: To get your API token, go to your Jenkins user page (top right in the interface). It is available in the "Configure" menu on the left of the page: "Show API token"
Make changes in your source code and commit the code to repository.
Your job, http://localhost:8080/jenkins/job/Gitcommittest/
, should be building.