【问题标题】:Jenkins build output set as current build descriptionJenkins 构建输出设置为当前构建描述
【发布时间】:2019-05-09 19:48:03
【问题描述】:

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

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

或者放置一些从当前构建中生成的其他人员。

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2016-07-29
      • 2017-07-19
      • 2015-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多