jenkins - 詹金斯`如果(sh'...')`
问题描述
如何让詹金斯sh
在条件内运行命令?如果它拉取以“WIP”开头的 git 提交,我希望它中止执行。
我的设想是:
stage('Build') {
steps {
// some steps ...
script {
if (sh "git log -1 --pretty='format:%B' | grep -q ^WIP") {
currentBuild.result = 'ABORTED'
return
}
}
// more steps ...
}
}
...但我的管道抱怨“期待')',发现'git log -1 --pretty ='格式:%B'| grep -q ^WIP'”
解决方案
似乎是 Groovy 解析器的问题。只需将参数括在括号中:
if (sh("git log -1 --pretty='format:%B' | grep -q ^WIP"))
推荐阅读
- python - 根据没有公共列的坐标合并数据框
- php - 使用按钮问题从表中删除 1 行
- unit-testing - Vue.js vuetify test-utils 测试:单元失败
- coldfusion - Coldfusion 11 应用程序服务器在 Windows 10 中自动停止
- c - 检查“NULL”指针时的“无法访问代码”警报
- android - Android Studio:预览页面上没有组件的属性
- python - tf.contrib.ffmpeg.decode_audio 替换?
- arrays - How to save a 2D array to a Script Property in Properties Service in Google App Script?
- javascript - 捕获表中的多个 td 元素
- c - C:无法使用取模运算符将零钱分解为面额,存储到数组中并将输出打印给用户