Merge branch 'test' into dev
This commit is contained in:
Vendored
+11
-6
@@ -73,12 +73,17 @@ pipeline {
|
||||
env.RESOLVED_ENVIRONMENT = resolvedEnvironment
|
||||
echo "Job ${env.JOB_BASE_NAME} 使用部署环境: ${env.RESOLVED_ENVIRONMENT}"
|
||||
|
||||
String requestedRepository = params.IMAGE_REPOSITORY?.trim()
|
||||
if (!requestedRepository || requestedRepository == 'registry.example.com/your-group/baiyue-firstleg') {
|
||||
error('必须填写真实镜像仓库地址')
|
||||
}
|
||||
if (requestedRepository.contains('://') || !requestedRepository.contains('/')) {
|
||||
error('IMAGE_REPOSITORY 格式错误:请填写 host[:port]/owner/image,不要包含 http:// 或 https://')
|
||||
String requestedRepository
|
||||
if (['development', 'test'].contains(env.RESOLVED_ENVIRONMENT)) {
|
||||
requestedRepository = '172.31.198.7:10082/java-project/baiyue-firstleg'
|
||||
} else {
|
||||
requestedRepository = params.IMAGE_REPOSITORY?.trim()
|
||||
if (!requestedRepository || requestedRepository == 'registry.example.com/your-group/baiyue-firstleg') {
|
||||
error('预发布/生产环境必须填写真实镜像仓库地址')
|
||||
}
|
||||
if (requestedRepository.contains('://') || !requestedRepository.contains('/')) {
|
||||
error('IMAGE_REPOSITORY 格式错误:请填写 host[:port]/owner/image,不要包含 http:// 或 https://')
|
||||
}
|
||||
}
|
||||
echo "${env.RESOLVED_ENVIRONMENT} 环境使用共享镜像仓库: ${requestedRepository}"
|
||||
env.RESOLVED_IMAGE_REPOSITORY = requestedRepository
|
||||
|
||||
+3
-1
@@ -63,7 +63,9 @@ pipeline {
|
||||
}
|
||||
String sourceCommit = params.SOURCE_COMMIT?.trim()
|
||||
String imageTag = params.IMAGE_TAG?.trim()
|
||||
String imageRepository = params.IMAGE_REPOSITORY?.trim()
|
||||
String imageRepository = ['development', 'test'].contains(params.ENVIRONMENT)
|
||||
? '172.31.198.7:10082/java-project/baiyue-firstleg'
|
||||
: params.IMAGE_REPOSITORY?.trim()
|
||||
|
||||
if (!sourceCommit) {
|
||||
sourceCommit = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||
|
||||
@@ -24,6 +24,7 @@ test('production deployments cannot skip tests', () => {
|
||||
test('Java builds use the shared builder pool and deploy on the target environment node', () => {
|
||||
assert.match(pipeline, /agent \{ label 'java-builder' \}/)
|
||||
assert.match(pipeline, /params\.ENVIRONMENT == 'development' \? 'java-dev' : 'master'/)
|
||||
assert.match(pipeline, /\['development', 'test'\]\.contains\(params\.ENVIRONMENT\)/)
|
||||
assert.match(pipeline, /172\.31\.198\.7:10082\/java-project\/baiyue-firstleg/)
|
||||
assert.match(pipeline, /docker push \$\{image\}/)
|
||||
assert.match(deployScript, /pull \$SERVICES/)
|
||||
|
||||
Reference in New Issue
Block a user