Jenkinsfile中可能有注释吗?如果是这样,语法是什么?
我正在使用声明性管道语法。
我要注释掉下面的“发布”部分,直到我的SMTP服务器正常工作为止。
pipeline {
agent { label 'docker-build-slave' }
environment {
IMAGE = 'registry.gitlab.com/XXXXX/bible-server'
DOCKER_REGISTRY_CREDENTIALS = credentials('DOCKER_REGISTRY_CREDENTIALS')
}
options {
timeout(10)
}
stages {
stage('Test') {
steps {
sh 'yarn'
sh 'npm test'
}
}
stage('Build') {
when {
branch '*/master'
}
steps {
sh 'docker login -u ${DOCKER_REGISTRY_CREDENTIALS_USR} -p ${DOCKER_REGISTRY_CREDENTIALS_PSW} registry.gitlab.com'
sh 'docker build -t ${IMAGE}:${BRANCH_NAME} .'
sh 'docker push ${IMAGE}:${BRANCH_NAME}'
}
}
stage('Deploy') {
when {
branch '*/master'
}
steps {
echo 'Deploying ..'
}
}
}
post {
success {
mail to: "XXXXX@gmail.com", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Yay, we passed."
}
failure {
mail to: "XXXXX@gmail.com", subject:"FAILURE: ${currentBuild.fullDisplayName}", body: "Boo, we failed."
}
}
}
2
每当您对Jenkinsfiles遇到此类语言问题时,请记住它们主要是GROOVY脚本。因此,如果添加关键字“ groovy”而不是“ Jenkinsfile”,则可能会发现更多结果。
—
劳尔·萨利纳斯-蒙塔古多