首页 > 解决方案 > 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.

标签: jenkinsjenkins-pipeline

解决方案


知道了。看起来关键是在命令前加上 @ 前缀,以防止命令本身包含在输出中

    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}"
  }

推荐阅读