Article Directory
The initial use jenkins
[A] Introduction
Jenkins is an open source, providing continuous integration-friendly operator interface (CI) tools, originated in Hudson (Hudson is commercially available), mainly used for continuous, automated build / test software project, monitor the operation of external tasks (this abstract and let us write, no explanation). Jenkins written in the Java language, runs Tomcat and other popular servlet container can also be run independently. Usually with version management tool (SCM), building tools in combination. Commonly used version control tools SVN, GIT, build tools Maven, Ant, Gradle.
[Two] Installation
2.1 docker install jenkins
https://blog.csdn.net/wenge1477/article/details/103828680
2.2 tomcat跑jenkins
- 下载war包
tomcat:https://tomcat.apache.org/download-80.cgi
jenkins:https://jenkins.io/download/ - Tomcat run
to
put the downloaded package on the war tomcat install webapps folder file address (starts with the tomcat start)
2.3 jar packet format run jenkins
- 下载jar
jenkins:https://jenkins.io/download/ - 运行jar包
java -jar jenkins.war --httpPort=8080
[Three] integration gitlab
3.1 gitlab New Project
3.2 gitlab generation Tokens
Tokens are generated for use jenkins, jenkins gitlab to call the api, authentication is required
Add Project on 3.3 jenkins
3.4 jenkins configuration items
pipeline {
agent any
stages {
stage('pull code') {
steps {
echo 'pull code'
git branch: 'develop', credentialsId: '47.100.21.42', url: 'http://git.xhrtas.com/fengsri/cloud-eureka-server.git'
sh 'chmod 777 /var/jenkins_home/workspace/eureka-server-pipeline/build.sh'
sh 'chmod 777 /var/jenkins_home/workspace/eureka-server-pipeline/run.sh'
}
}
stage('build code') {
steps {
echo 'build code'
sh '/var/jenkins_home/workspace/eureka-server-pipeline/build.sh'
}
}
stage('unit test') {
steps {
echo 'unit test'
}
}
stage('deploy code') {
steps {
echo 'deploy code'
sh '/var/jenkins_home/workspace/eureka-server-pipeline/run.sh'
}
}
}
}
3.5 gitlab configuration webhook
3.6 Test
As long as I am every merge onto the master, went back to the trigger webhook jenkins, jenkins will go pull the code on gitlab, automated build, test, release code