【问题标题】:Build only when a file contains specific text仅在文件包含特定文本时构建
【发布时间】:2023-03-26 10:02:01
【问题描述】:

我想知道如何仅在文件包含特定文本时继续构建?

如果文本不正确,我希望构建失败,否则继续构建。

【问题讨论】:

标签: jenkins jenkins-plugins jenkins-cli


【解决方案1】:

更新您的脚本以在文件不包含文本时返回非零退出状态。通过sh 步骤运行您的 shell 脚本,如下所示:

sh '/path/to/your/script_that_checks_another_file_for_certain_text.sh'

完整的管道:

pipeline {
  agent { label 'docker' }
  stages {
    stage('build') {
      steps {
        sh '/path/to/your/script_that_checks_another_file_for_certain_text.sh'
        echo 'this will not happen if the above script returns a bad exit status'
      }
    }
  }
}

【讨论】:

    猜你喜欢
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2019-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    相关资源
    最近更新 更多