欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

jenkinspipeline记录

时间:2023-07-13

def riqi=’’
def basedir=‘biz-module-storage/biz-module-storage-start’
import java.text.SimpleDateFormat
pipeline {
agent {
node {
label ‘maven’
}
}
environment {
DATETAG=""
DEPLOY_ENV_SELECT=“test”
DEPLOY_ENV=‘dev’
BRANCH_ENV=‘dev’
PROJECT=‘p-lms-istio’
VERSION=‘test’
DOCKER_NAME=‘biz-module-storage’
DOCKER_HUB=‘hub.fqi.com’
DEPLOYMENT=‘biz-module-storage’
ConTAINER=‘biz-module-storage’
MODULE = ‘biz-module-storage’
}

stages {
stage(‘获取代码’) {
steps {
git(credentialsId: ‘gitlab’, url: ‘ssh://git@192.168.3.4:7003/root/p-lms-back.git’, branch: ‘istio’, changelog: true, poll: false)
}
}
stage(‘Maven 构建’){
steps {
container (‘maven’) {
/dir(‘jeecg-boot-starter/jeecg-boot-starter-cloud’){
sh ‘mvn -f pom.xml -Dmaven.test.skip=true -U -P test clean install’
}
dir(‘biz-module-base’){
sh ‘mvn -f pom.xml -Dmaven.test.skip=true -U -P test clean install’
}
/
sh ‘mvn -f pom.xml -Dmaven.test.skip=true -U -P test clean install’
}
}
}
stage(‘并行检查’) {
parallel {

stage('打包Docker'){ steps { container ('maven') { echo "start build image" // build镜像 dir(basedir) { //切换文件夹 执行如下命令 sh 'docker build --build-arg DEPLOY_ENV_SELECT=$DEPLOY_ENV_SELECT -t $PROJECT/$DOCKER_NAME-$DEPLOY_ENV:$BUILD_NUMBER .' // 登录镜像仓库 sh 'docker login -u admin -p admin@123 $DOCKER_HUB' sh 'docker tag $PROJECT/$DOCKER_NAME-$DEPLOY_ENV:$BUILD_NUMBER $DOCKER_HUB/$PROJECT/$DOCKER_NAME-$DEPLOY_ENV:$BUILD_NUMBER' // 推送镜像到镜像仓库 sh 'docker push $DOCKER_HUB/$PROJECT/$DOCKER_NAME-$DEPLOY_ENV:$BUILD_NUMBER' } } } } stage('sonarqube analysis') { steps { container('maven') { withCredentials([string(credentialsId: "sonar", variable: 'SONAR_TOKEN')]) { withSonarQubeEnv('sonar') { dir('biz-module-storage') { sh 'mvn sonar:sonar -Dsonar.projectKey=biz-module-storage -Dsonar.host.url=http://192.168.3.66:10893 -Dsonar.login=2fc7d3229a146862c824bbbb5f959761eb58b872' } } } timeout(time: 1, unit: 'HOURS') { waitForQualityGate false } } } } }}stage('发布kubernetes') { agent { node { label 'base' } } steps { container('base') { sh 'kubectl set image deployment/$MODULE-v1 $MODULE=$DOCKER_HUB/$PROJECT/$DOCKER_NAME-$DEPLOY_ENV:$BUILD_NUMBER -n p-lms-mesh' } }}

}
}

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。