jenkins - With Jenkins Declarative pipeline, how do I set the value of a variable in a stage based on exe output output?
问题描述
With Jenkins Declarative pipeline, how do I set the value of a variable in a stage based on .exe output output?
The jenkins instance is running on windows OS. The variable can either be global to the job run or local within a stage.
解决方案
知道了。看起来关键是在命令前加上 @ 前缀,以防止命令本身包含在输出中
stage('Build') {
steps {
script {
// Its very important to prefix the script with "@" or else the command itself will be included in the output
GITVERSION_FULLSEMVAR = bat( script: '@GitVersion.exe /showvariable FullSemVer', returnStdout: true )
}
bat "dotnet build /p:Version=${GITVERSION_FULLSEMVAR}"
}
推荐阅读
- .net - Blazor/dotnet 5.0.0:在 InputSelect 中设置选定值
- python-3.x - 为什么轴不延伸 plt.xlim(-1.5, 1.5)?
- c++ - Visual Studio Code - 包含路径问题头文件 C++ (MinGW)
- javascript - 对带有确认框的已购买订单使用 If 和 Else 语句
- python - 如何从我的 sparql 查询中过滤无定义概念?
- c# - PersonalDataAttribute 有什么用?
- python - 如何获取字符串的前 n 个字符和最后一个字符?
- android-studio - Android Studio 没有开始构建 Flutter 项目
- sapui5 - 如何迭代嵌套模型并基于它生成元素
- php - Lumen - 语言环境文件位置