Warm tip: This article is reproduced from serverfault.com, please click

groovy-Jenkins:注释可以添加到Jenkins文件中吗?

(groovy - Jenkins: Can comments be added to a Jenkinsfile?)

发布于 2017-02-18 01:11:51

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."
    }
  }
}
Questioner
danday74
Viewed
0
BMitch 2017-02-18 11:01:06

Jenkinsfile是用groovy编写的,它使用Java(和C)形式的注释:

/* this
   is a
   multi-line comment */

// this is a single line comment