Tul*_*ika 6 jenkins cloudbees jenkins-pipeline
我正在为我的 .net 项目使用 Jenkins Pipeline。我不想使用默认内部版本号,所以我尝试在 groovy 中使用以下命令设置内部版本号。
def short_hash = bat(script: 'git log --pretty=format:\'%%h\' -n 1', returnStdout: true)
currentBuild.displayName = '0.0.' + "${env.BUILD_NUMBER}" +'.' + short_hash
Run Code Online (Sandbox Code Playgroud)
我观察到的是 short_hash 具有批处理命令的值以及结果。
此处的 jenkins 文档指出“脚本执行批处理脚本。允许多行。使用 returnStdout 标志时,您可能希望用 @ 作为前缀,以免命令本身包含在输出中。”
我尝试使用@,但在执行时出错。任何指针?
小智 1
def short_hash = bat(script: '@git log --pretty=format:\'%%h\' -n 1', returnStdout: true)
currentBuild.displayName = '0.0.' + "${env.BUILD_NUMBER}" +'.' + short_hash
Run Code Online (Sandbox Code Playgroud)
在git命令前加上@
| 归档时间: |
|
| 查看次数: |
3428 次 |
| 最近记录: |