Jenkins构建输出集作为当前构建描述

时间:2019-05-09 19:48:03

标签: bash jenkins groovy continuous-integration jenkins-pipeline

我想在#bash输出中的jenkins作业中设置当前的构建描述

Jenkins构建输出设置为当前构建描述

例如设置修订和从字符串和选择参数分支,我这样做是这样的:

   parameters {
       string(defaultValue: "", description: '11.00', name: 'REVISION')
       choice(name: 'BRANCH', choices: 'trunk\nupdate', description: 'Branch')
   }

   stage('Set build') {
      steps {
         script {
             // Set build parameters
             currentBuild.description = "$REVISION $BRANCH"
         }
      }
   }

假设我要执行磁盘空间%#bash并将其放在描述中...

   stage('bash') {
      steps {
         script {
         sh '''
            DISK_SIZE="$(df -h --output='pcent' /mnt | grep -v "Use%")
         }
        currentBuild.description = "$DISK_SIZE"
      }
   }

例如,我想在构建说明中放入磁盘%。在这种情况下,我希望在描述%30

或者放置其他一些由当前版本生成的人员。

1 个答案:

答案 0 :(得分:2)

您可以使用returnStdout选项告诉sh命令返回其标准输出。

myOutput = sh(script: '$(df -h --output='pcent' /mnt | grep -v "Use%")', returnStdout: true)

currentBuild.description = myOutput
相关问题