ci: 添加ci/cd
This commit is contained in:
27
Jenkinsfile
vendored
Normal file
27
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
pipeline {
|
||||
agent none
|
||||
stages {
|
||||
stage('Build Image With localhost') {
|
||||
agent { label 'LocalHost' } // 在标签为'linux-build'的节点上执行
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
echo 'Start Build'
|
||||
sh "docker ps -a --format '{{.ID}} {{.Names}}' | awk '{if (\$2 !~ /^1Panel-jenkins/) print \$1}' | xargs -r docker stop"
|
||||
sh 'docker compose -f ./deploy/docker-compose.yml up -d --build'
|
||||
sh 'docker start \$(docker ps -a -q)'
|
||||
sh "docker restart \$(docker ps -a | grep kami_ | awk '{print \$1}')"
|
||||
echo 'Build success'
|
||||
} catch (err) {
|
||||
echo err.getMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
post { // 添加post指令处理阶段完成后的情况
|
||||
failure {
|
||||
echo 'Build failed, but continuing to the next stage...'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user