39 lines
1.3 KiB
Groovy
39 lines
1.3 KiB
Groovy
pipeline {
|
|
agent { label 'java-test' }
|
|
options {
|
|
timestamps()
|
|
disableConcurrentBuilds()
|
|
}
|
|
stages {
|
|
stage('检查测试发布参数') {
|
|
steps {
|
|
script {
|
|
if (env.JOB_BASE_NAME?.endsWith('-dev') || env.JOB_BASE_NAME?.endsWith('-prod')) {
|
|
error('当前仅支持 test,请使用测试环境 Job')
|
|
}
|
|
env.IMAGE_TAG = sh(script: 'git rev-parse --short=12 HEAD', returnStdout: true).trim()
|
|
}
|
|
sh '''set -eu
|
|
export API_UPSTREAM="${API_UPSTREAM:-http://gateway:9000}"
|
|
export TEST_NETWORK="${TEST_NETWORK:-firstleg-test-network}"
|
|
: "${CLIENT_WEB_URL:?CLIENT_WEB_URL 未设置}"
|
|
docker network inspect "$TEST_NETWORK" >/dev/null
|
|
docker compose -f docker-compose.test.yml config --quiet
|
|
'''
|
|
}
|
|
}
|
|
stage('构建并部署测试前端') {
|
|
steps {
|
|
sh '''set -eu
|
|
docker compose -f docker-compose.test.yml build --pull=false
|
|
docker compose -f docker-compose.test.yml up -d --wait --wait-timeout 120
|
|
docker compose -f docker-compose.test.yml exec -T admin-web wget -qO- http://127.0.0.1/healthz
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
failure { sh 'docker compose -f docker-compose.test.yml logs --tail=100 || true' }
|
|
}
|
|
}
|