项目用git管理
1.GIT新建项目
2.创建本地GIE 仓库
3.
4.commit /push
5.
6.push
JenKins
1.登录JenKins 选流水线
2.配置代码
非maven版
node {
stage('git pull loginservice') { // for display purposes
// Get some code from a GitHub repository
git credentialsId: '9de70303-0f7c-4fc4-9e6d-15719b55637b', url: 'http://172.31.***.***/IT/TQM.git'
}
def imagesName = 'registry.****-assistance.com.cn/bmwtest/tqm**:0.0.07'
stage('Image Build And Push'){
withDockerServer([uri: 'tcp://127.0.0.1:2375']) {
docker.withRegistry('http://registry.***-assistance.com.cn', 'a905da64-23a0-4b0d-931c-f880aaa7d388') {
docker.build(imagesName,'--file=./Dockerfile --build-arg JAR_FILE=./*.war .').push()
}
}
}
stage('deployment message service'){
}
}
Maven版
```bash
node {
stage('git pull loginservice') { // for display purposes
// Get some code from a GitHub repository
git credentialsId: '9de70303-0f7c-4fc4-9e6d-15719b55637b', url: 'http://172.31.***.***/IT/self***ing.git'
}
stage('Build jar for docker build') {
// Run the maven build
if (isUnix()) {
withEnv(["PATH+MAVEN=${tool 'jdk 8'}/bin"]) {
withEnv(["PATH+MAVEN=${tool 'apache-maven-3.5.4'}/bin"]) {
sh "mvn -B -Dmaven.repo.local=/var/lib/jenkins/maven-repositories/1 -s /h**e/***/maven/apache-maven-3.5.4/conf/settings.xml -gs /h**e/***/maven/apache-maven-3.5.4/conf/settings.xml clean package -DskipTests"
}
}
} else {
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean package/)
}
}
def imagesName = 'registry.*****-assistance.com.cn/bmwtest/se***ice:0.0.43'
stage('Image Build And Push'){
withDockerServer([uri: 'tcp://127.0.0.1:2375']) {
docker.withRegistry('http://registry.***-assistance.com.cn', 'a905da64-23a0-4b0d-931c-f880aaa7d388') {
docker.build(imagesName,'--file=./src/main/docker/Dockerfile --build-arg JAR_FILE=./target/*.jar .').push()
}
}
}
stage('deployment message service'){
}
}