ϵͳ
[root@i-vzdytl5t jdk1.8.0_144]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
安装docker
yum install docker -y systemctl enable docker systemctl start docker
启动 jenkinsci/blueocean
[root@i-vzdytl5t jenkinsblue]# ls -l total 4 -rwxr-xr-x 1 root root 213 Jun 23 17:20 blue.sh [root@i-vzdytl5t jenkinsblue]# cat blue.sh #!/bin/sh docker run \ --rm \ -u root \ -p 9999:8080 \ -v /opt/jenkins-data:/var/jenkins_home \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /opt/jenkinsci/blueocean:/home \ jenkinsci/blueocean [root@i-vzdytl5t jenkinsblue]# sh blue.sh Unable to find image 'jenkinsci/blueocean:latest' locally Trying to pull repository docker.io/jenkinsci/blueocean ... latest: Pulling from docker.io/jenkinsci/blueocean ff3a5c916c92: Already exists a8906544047d: Pull complete ae9db8d675e1: Pull complete 85fba234e19f: Pull complete 6afa091c7023: Pull complete c6c8a38990e0: Pull complete 880f546870ba: Pull complete b1203e84c055: Pull complete 51bd360e7147: Pull complete 987a4c2872a9: Pull complete 2f35dab8a15d: Pull complete 53116fdf277c: Pull complete ... ... Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: 271f66e863c74499aee96b5d910f65fc This may also be found at: /var/jenkins_home/secrets/initialAdminPassword ************************************************************* ************************************************************* ...
把271f66e863c74499aee96b5d910f65fc
记录下来,用来初始化jenkinsci
执行的脚本
node{ stage('get clone'){ //check CODE echo 'Checkout==========》》》' checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://source.enncloud.cn/qinzhao/spring-boot-demo.git']]]) } //定义mvn环境 def mvnHome = tool 'M3' env.PATH = "${mvnHome}/bin:${env.PATH}" stage('mvn test'){ //mvn 测试 sh "mvn test" } stage('mvn build'){ //mvn构建 sh "mvn clean install -Dmaven.test.skip=true" } stage('deploy'){ //执行部署脚本 sh "ls -l target" echo "deploy ......" } def dockerfile = 'Dockerfile' def customImage = docker.build("10.39.47.22/qinzhao/demo:v1.1", "-f ${dockerfile} .") customImage.push() }
点击【Open Blue Ocean】按钮
添加执行按钮
执行完成