码迷,mamicode.com
首页 > 其他好文 > 详细

docker与jenkins学习

时间:2018-10-22 14:49:32      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:sla   setting   gen   generate   gre   export   dap   url   tin   

docker命令:

docker create <image-id>
docker start <container-id>
docker run <image-id> = docker create <image-id> + docker start <container-id>
docker ps
docker ps -a
docker images
docker images –a
docker stop <container-id>
docker kill <container-id>
docker pause <container-id>
docker rm <container-id>
docker rmi <image-id>
docker commit <container-id>
docker build
docker exec <running-container-id>
docker inspect <container-id> or <image-id>
docker save <image-id>
docker export <container-id>
docker history <image-id>

 

Dockerfile

FROM jdk8:slim

ADD target/udap-user.jar app.jar

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-jar" , "-Xms128m","-Xmx128m" ,"/app.jar"]


Jenkinsfile

pipeline {

agent { label ‘iclass5‘ }

stages {

//slave 机器执行编译打包上传
stage(‘Checkout‘) {

steps {

echo ‘start to check from github‘

checkout([$class: ‘GitSCM‘,
branches: [[name: ‘*/master‘]],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: ‘SparseCheckoutPaths‘,
sparseCheckoutPaths:[[$class:‘SparseCheckoutPath‘, path:‘udap-user‘]]]
], submoduleCfg: [],
userRemoteConfigs: [[credentialsId: ‘github-wwlleo0730‘, url: ‘https://github.com/udap/mediabox‘]]])
}
}

stage(‘mvn build & test‘){

steps {

echo ‘start to mvn build‘

sh "docker run -i --rm -v ${env.WORKSPACE}/udap-user:/usr/src/workspace -v /root/.m2/repository/:/root/.m2/repository -v /opt/maven/settings.xml:/root/.m2/settings.xml -w /usr/src/workspace maven mvn clean package -U -Dmaven.test.skip=true"
}
}

stage(‘remove old container‘){

steps{

sh ‘‘‘CID=$(docker ps | grep iclass.cn/$JOB_NAME | awk \‘{print $1}\‘)
if [ "$CID" != "" ];then
docker rm -f $CID
fi‘‘‘
}

}

stage(‘rebuild image‘){

steps {

sh ‘‘‘CID=$(docker images | grep iclass.cn/$JOB_NAME | awk \‘{print $1}\‘)

if [ "$CID" != "" ];then
docker rmi iclass.cn/$JOB_NAME
fi‘‘‘

script {
docker.build(‘iclass.cn/$JOB_NAME‘,‘./udap-user‘)
}
}
}

stage(‘restart container‘){

steps{

echo ‘start..‘
sh ‘docker run -d --name $JOB_NAME -p 4010:4010 -e "SPRING_PROFILES_ACTIVE=test" -e "EUREKA_INSTANCE_IP-ADDRESS=10.80.228.221" iclass.cn/$JOB_NAME‘
}

}
}
}

docker与jenkins学习

标签:sla   setting   gen   generate   gre   export   dap   url   tin   

原文地址:https://www.cnblogs.com/stanljj/p/9829412.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!