dan*_*y74 138 groovy comments jenkins jenkins-pipeline
Jenkins文件中是否有注释?如果是这样,语法是什么?
我正在使用声明性管道语法.
我想在下面的"帖子"部分注释掉,直到我的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."
}
}
}
Run Code Online (Sandbox Code Playgroud)
BMi*_*tch 216
Jenkinsfile是用groovy编写的,它使用Java(和C)形式的注释:
/* this
is a
multi-line comment */
// this is a single line comment
Run Code Online (Sandbox Code Playgroud)
您可以为每一行使用块(/***/)或单行注释(//).你应该在sh命令中使用"#".
阻止评论
/*
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."
}
}
*/Run Code Online (Sandbox Code Playgroud)
单线
// 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."
// }
// }Run Code Online (Sandbox Code Playgroud)
在'sh'命令中注释
stage('Unit Test') {
steps {
ansiColor('xterm'){
sh '''
npm test
# this is a comment in sh
'''
}
}
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
81162 次 |
| 最近记录: |