如何将Jenkins作业输出发布到松弛通知

时间:2019-03-29 09:29:20

标签: jenkins

我试图将Jenkins作业脚本输出发布到松弛通知中:但是我无法在松弛通知设置中访问输出。

除了/env-vars.html/以外的其他变量,我无法访问任何其他变量。

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

在Jenkins中,除env vars之外,目前不支持获取其他变量。我们可以使用“ Environment Injector”插件,但是我不确定该插件。

对于您的情况,您可以使用下面的脚本管道创建“管道”

node('JENKINS_NODE') {
    git([url: 'GITHUB_REPO_URL', branch: 'BRANCH'])
    def getResult

    stage ('Execute Script') {
      getResult = sh(
        script: "python test.py",
        returnStdout: true,
      )
    }
    stage ('Send Slack Notification') {
      slackSend channel: '#YOUR_SLACK_CHANNEL', color: 'good', message: getResult'
    }
}