大概就是这么个流程简单来说就是:拉代码—》编译—》打镜像—》推镜像—》部署到 k8s 中,下面的 pipeline 就是在这条主线上进行,根据情况进行增加
pipeline {
agent { label 'pdc&&jdk8' }
environment {
git_addr = "代码仓库地址"
git_auth = "拉代码时的认证ID"
pom_dir = "pom文件的目录位置(相对路径)"
server_name = "服务名"
namespace_name = "服务所在的命名空间"
img_domain = "镜像地址"
img_addr = "${img_domain}/cloudt-safe/${server_name}"
// cluster_name = "集群名"
}
stages {
stage('Clear dir') {
steps {
deleteDir()
}
}
stage('Pull server code and ops code') {
parallel {
stage('Pull server code') {
steps {
script {
checkout(
[
$class: 'GitSCM',
branches: [[name: '${Branch}']],
userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_addr}"]]
]
)
}
}
}
stage('Pull ops code') {
steps {
script {
checkout(
[
$class: 'GitSCM',
branches: [[name: 'pipeline-0.0.1']], //拉取的构建脚本的分支
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'DEPLOYJAVA']], //DEPLOYJAVA: 把代码存放到此目录中
userRemoteConfigs: [[credentialsId: 'chenf-o', url: '构建脚本的仓库地址']]
]
)
}
}
}
}
}
stage('Set Env') {
steps {
script {
date_time = sh(script: "date +%Y%m%d%H%M", returnStdout: true).tr