【发布时间】:2023-03-26 10:02:01
【问题描述】:
我想知道如何仅在文件包含特定文本时继续构建?
如果文本不正确,我希望构建失败,否则继续构建。
【问题讨论】:
-
到目前为止,您的 Jenkinsfile 是什么样的?你试过什么?
-
文件位于作业配置为运行的虚拟机上。我有一个 shell 脚本来检查内容。
标签: jenkins jenkins-plugins jenkins-cli
我想知道如何仅在文件包含特定文本时继续构建?
如果文本不正确,我希望构建失败,否则继续构建。
【问题讨论】:
标签: jenkins jenkins-plugins jenkins-cli
更新您的脚本以在文件不包含文本时返回非零退出状态。通过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'
}
}
}
}
【讨论】: