加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 6.83 KB
一键复制 编辑 原始数据 按行查看 历史
pipeline {
agent { label 'docker' }
stages {
stage('submodule pull') {
steps {
dir("${env.WORKSPACE}/openatc-doc") {
sh 'pwd'
sh 'git submodule update --init --recursive'
}
}
}
stage('Build Docs') {
agent {
docker {
image 'openatc/mkdocs-tools:1.4.2'
args '-e ENABLE_PDF_EXPORT=1'
reuseNode true
}
}
steps {
dir("${env.WORKSPACE}/openatc-doc/OpenATCAdminManual_cn") {
sh 'mkdocs build --no-directory-urls'
}
dir("${env.WORKSPACE}/openatc-doc/OpenATCAdminManual_eng") {
sh 'mkdocs build --no-directory-urls'
}
dir("${env.WORKSPACE}/openatc-doc/OpenATCconfigerManual_cn") {
sh 'mkdocs build'
}
dir("${env.WORKSPACE}/openatc-doc/OpenATCconfigerManual_eng") {
sh 'mkdocs build'
}
dir("${env.WORKSPACE}/openatc-doc") {
sh 'rm UserManual -rf'
sh 'rm configserver -rf'
sh 'mkdir -p UserManual/openatcAdmin'
sh 'mkdir -p configserver/UserManual/openatcConfig'
sh 'cp -r OpenATCAdminManual_cn/site/ UserManual/openatcAdmin/zh/'
sh 'cp -r OpenATCAdminManual_eng/site/ UserManual/openatcAdmin/en/'
sh 'cp -r OpenATCconfigerManual_cn/site/ configserver/UserManual/openatcConfig/zh/'
sh 'cp -r OpenATCconfigerManual_eng/site/ configserver/UserManual/openatcConfig/en/'
}
}
}
stage('Build Configure') {
agent {
docker {
image 'openatc/pnpm:6-node14'
args '-v /data/.pnpm-store:/root/.local/share/pnpm/store --entrypoint=\'\''
reuseNode true
}
}
steps {
dir("${env.WORKSPACE}/OpenATC-Admin-ui/OpenATC-Configer-web") {
sh 'pnpm install --no-frozen-lockfile'
sh 'pnpm run package:prod'
sh 'pnpm run build'
sh 'tar -zcvf Configdist.tar.gz dist'
sh 'cp -r ../../openatc-doc/configserver/UserManual dist'
sh 'tar -zcvf ConfigWithUserManual.tar.gz dist'
}
}
}
stage('Build Web') {
agent {
docker {
image 'openatc/pnpm:6-node14'
args '-v /data/.pnpm-store:/root/.local/share/pnpm/store --entrypoint=\'\''
reuseNode true
}
}
steps {
dir("${env.WORKSPACE}/OpenATC-Admin-ui/OpenATC-Admin-web") {
sh 'pnpm install --no-frozen-lockfile'
sh 'pnpm run build'
sh 'rm ../../OpenATC-Admin-server/agent/src/main/resources/static -rf'
sh 'cp -r ../../openatc-doc/UserManual dist'
sh 'cp -r ../../openatc-doc/configserver/UserManual dist'
sh 'cp -r dist ../../OpenATC-Admin-server/agent/src/main/resources/static'
// sh 'cp -r ../../openatc-doc/UserManual ../../OpenATC-Admin-server/agent/src/main/resources/static'
sh 'tar -zcvf admindist.tar.gz dist'
}
}
}
stage('Build Server Agent') {
agent {
docker {
image 'maven:amazoncorretto'
args '-v /data/.m2:/root/.m2 --entrypoint=\'\''
reuseNode true
}
}
steps {
dir("${env.WORKSPACE}/OpenATC-Admin-server") {
sh 'mvn clean install'
}
}
}
// stage('Build Configer Server') {
// agent {
// docker {
// image 'maven:amazoncorretto'
// args '-v /data/.m2:/root/.m2 --entrypoint=\'\''
// reuseNode true
// }
// }
// steps {
// dir("${env.WORKSPACE}/OpenATC-Admin-server/configserver") {
// sh 'mvn clean package'
// }
// }
// }
stage('Publish') {
steps {
// archiveArtifacts artifacts: 'OpenATC-Admin-server/target/agent.jar, OpenATC-Admin-server/configserver/target/ConfigServer.jar, OpenATC-Admin-ui/OpenATC-Configer-web/Configdist.tar.gz, OpenATC-Admin-ui/OpenATC-Admin-web/admindist.tar.gz', followSymlinks: false, onlyIfSuccessful: true
archiveArtifacts artifacts: 'OpenATC-Admin-server/target/agent.jar, OpenATC-Admin-ui/OpenATC-Configer-web/Configdist.tar.gz,OpenATC-Admin-ui/OpenATC-Configer-web/ConfigWithUserManual.tar.gz, OpenATC-Admin-ui/OpenATC-Admin-web/admindist.tar.gz', followSymlinks: false, onlyIfSuccessful: true
}
}
stage('Building image & push') {
steps {
script {
def buildImg
echo "building img for branch: ${env.BRANCH_NAME} and tag: ${env.TAG_NAME}"
if (env.BRANCH_NAME == 'master' || (env.TAG_NAME) != null ) {
buildImg=docker.build('openatc/openatc-admin:latest', "${env.WORKSPACE}/OpenATC-Admin-server/agent")
} else {
buildImg=docker.build("openatc/openatc-admin-${env.BRANCH_NAME}:latest", "${env.WORKSPACE}/OpenATC-Admin-server/agent")
}
docker.withRegistry('', 'openatc-docker-hub') {
buildImg.push()
}
}
}
}
stage('Add Docker Version Tag') {
when {
buildingTag()
}
steps {
sh "docker tag openatc/openatc-admin:latest openatc/openatc-admin:${env.TAG_NAME}"
script {
docker.withRegistry('', 'openatc-docker-hub') {
docker.image("openatc/openatc-admin:${env.TAG_NAME}").push()
}
}
}
}
}
post {
failure{
emailext to: "${env.OPENATC_FAILURE_MAIL_RECV}",
subject: "jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found here: ${env.BUILD_URL}"
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化