to implement a CI environment
- Create new item in Jenkins
- Configure the project source path in Jenkins
- Configure the automatic execution strategy (trigger) in Jenkins. We want to configure the latest code to be automatically repackaged every time the project on gitlab is submitted and the mearge request is made, so we only need to open Poll SCM here.
- Configure the package execution command in Jenkins. Note that the maven project is executed by the mvn command by default, so we only need to enter the mvn goals we want to execute in the build, without adding mvn
- Configure webhook in gitlab project
- After the webhook is successfully created, click, test, and then go to the item just created on Jenkins, you will find that Jenkins has automatically packaged it for us, and then it will be automatically repackaged when the code on gitlab changes.
The selected Credentials must have permission to access the corresponding project on gitlab.
5. Jenkins implements parameterized construction
When we have many branches on git, we can choose the build version when building.
5.1 Install the plugin extensible-choice-parameter.jpi
5.2 Add parameterized construction to the
jenkins Corresponding to the git address of the build project
5.3 renderings After the
addition , the original immediate build becomes the build with parameters
drop-down list is the version number corresponding to your own project, select it and then build, and write this in the source management selection branch build
The variable name
set
at Add post steps
so that after the current project is built, the selected branch version number will be passed to the
subproject in docker way
docker run -i -t -d -u root --name jenkins -p 8080:8080 -p 5000:5000 -v /jenkins/data/.m2:/root/.m2 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /jenkins/data:/var/jenkins_home -v /soft/jdk1.8:/var/local/jdk1.8 -v /home/data/soft/apache-maven-3.3.9:/var/local/apache-maven-3.3.9 -v /etc/localtime:/etc/localtime -v ./timezone:/etc/timezone jenkins