In the previous chapters we explained the Jenkins combined with. NET platform tools and some third-party tools for automatic Project Restoration, automatic compilation, automated testing, and automatic publishing. However, there is a key step in automating the process of listening to the source repository changes and pulling up the latest code from the repository before performing the steps just described.
Let's talk about how Jenkins listens to changes in the Git repository and, if there is a change, pulls up the latest code to compile, test, and publish.
First turn on Jenkins, we create a new freestyle project called POLLSCM,
We used to use only the build column, where we're going to set the souce Code management bar
The default option is none without any source control tools, and this is a combination of git, I chose git
After choosing Git to appear above, where the repository URL is the address of the Git repository, we enter the GIT address of the automatic project repository.
Below is the password we click Add, the following interface appears
Here we enter the user name, password these two are key, ID and description can lose also can not lose, finished click Add
A drop-down box will appear in the credentials bar
We select the username and password you just added
Here is the branch, because there is only one master branch in the test repository, as a demonstration we use the Master branch.
Then pull down to the builder triggers bar
This column before we used build periodically, here we choose Poll SCM, is constantly rotation SCM changes, if there are changes to pull
We tick poll SCM after the above content, we enter in the schedule * * * * * * is not a password, every minute to query git changes, about the Git timed task format configuration can be seen in previous documents.
Here we no longer demonstrate how to build after a pull, and there is a complete example behind it.
We click Save, modify the local code and submit it once, after a minute to see if there is a build generated.
We modified the Readme file under the Tools folder in the sample code base and submitted it to trigger a build
After submission we see that the build is executing.
Here you may have questions about where Git pulled the project. In fact, it was pulled to the same folder under Workspace in the Jenkins installation directory (the name of the project is the same name as the project we created in the Jenkins Admin interface)
We open the Readme file under Workspace/pollscm/tools in the Jenkins directory (this file is empty)
You can see that the content we just submitted has been properly pulled.
Jenkins integrates with the. NET platform to monitor the GIT repository and automatically extracts the latest code compilation