1 Star 0 Fork 13K

一生无忧/pig

forked from lengleng/pig 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 4.02 KB
一键复制 编辑 原始数据 按行查看 历史
一生无忧 提交于 2023-03-15 16:09 . asdasd
pipeline {
agent any
parameters {
choice(
choices: [
'pig-gateway',
'pig-auth',
'pig-register',
'pig-upms-biz',
'pig-codegen',
'pig-monitor',
'pig-sentinel-dashboard',
'pig-xxl-job-admin',
'all'
],
name: 'ServicesDeploy',
description: '请选择要构建的服务,支持单个服务发布或全部服务发布'
)
}
environment {
HARBOR_CREDENTIAL_ID = 'aliyun-harbor'
GITLAB_CREDENTIAL_ID = 'gitlab'
REGISTRY = 'registry.cn-shenzhen.aliyuncs.com'
HARBOR_NAMESPACE = 'bill_k8s'
K8s_NAMESPACE = 'default'
}
stages {
stage('代码审查') {
steps {
script {
scannerHome = tool 'sonar'
// 设置为全局工具配置中Scanner的名称
}
withSonarQubeEnv('sonar') {
// 上面的SonarQub为系统配置中的Sonar的服务器名称
sh "${scannerHome}/bin/sonar-scanner -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=ui${BUILD_ID} -Dsonar.java.binaries=${WORKSPACE}"
}
}
}
stage('maven打包') {
steps {
//sh "mvn -Dmaven.test.skip=true clean package"
//sh "mvn clean verify sonar:sonar -Dsonar.projectKey=pig -Dsonar.host.url=http://175.24.181.244:9000 Dsonar.login=sqp_02291498fadce7bbb0a1e5df2de6685560562a27"
sh "echo '${ServicesDeploy} 进行maven构建'"
}
}
stage('构建镜像') {
steps {
script {
if (env.ServicesDeploy == "pig-upms-biz") {
sh "cd pig-upms/pig-upms-biz/ && docker build -f Dockerfile -t $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER ."
} else if (env.ServicesDeploy == "pig-codegen") {
sh "cd pig-visual/pig-codegen/ && docker build -f Dockerfile -t $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER ."
} else if (env.ServicesDeploy == "pig-monitor") {
sh "cd pig-visual/pig-monitor/ && docker build -f Dockerfile -t $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER ."
} else if (env.ServicesDeploy == "pig-sentinel-dashboard") {
sh "cd pig-visual/pig-sentinel-dashboard/ && docker build -f Dockerfile -t $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER ."
} else if (env.ServicesDeploy == "pig-xxl-job-admin") {
sh "cd pig-visual/pig-xxl-job-admin/ && docker build -f Dockerfile -t $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER ."
} else {
sh "cd ${ServicesDeploy} && docker build -f Dockerfile -t $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER ."
}
}
}
}
stage('推送镜像') {
steps {
withCredentials([
usernamePassword(
passwordVariable: 'HARBOR_PASSWORD',
usernameVariable: 'HARBOR_USERNAME',
credentialsId: "$HARBOR_CREDENTIAL_ID"
)
]) {
sh 'echo "$HARBOR_PASSWORD" | docker login $REGISTRY -u "$HARBOR_USERNAME" --password-stdin'
sh "docker push $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER"
sh "docker rmi $REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER"
}
}
}
stage('更新镜像') {
steps {
sh "/usr/local/bin/kubectl set image Deployment ${ServicesDeploy} ${ServicesDeploy}=$REGISTRY/$HARBOR_NAMESPACE/${ServicesDeploy}:$BUILD_NUMBER --record"
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/worry-free-life/pig.git
[email protected]:worry-free-life/pig.git
worry-free-life
pig
pig
master

搜索帮助