【问题标题】:Need to pass build fail notification of Git committer whenever a Jenkins build is triggered每当触发 Jenkins 构建时,需要通过 Git 提交者的构建失败通知
【发布时间】:2018-02-12 16:42:55
【问题描述】:

因此,我尝试使用 Jenkinsfile 进行管道(GIT 提交触发 CI 管道)通知,在该通知中,当 Jenkins 构建失败时收到通知的人会捕获异常。

catch (err) {
        currentBuild.result = "FAILURE"
            mail body: "project build error is here: ${env.BUILD_URL}" ,
            from: 'xxxx@yyyy.com',
            replyTo: 'yyyy@yyyy.com',
            subject: 'project build failed',
            to: "some@jdkjf.com"
        throw err
    }

to 字段中,我想传递动态 GIT 用户 ID(电子邮件)。应该通知导致构建失败的任何人。 我该怎么做?

【问题讨论】:

    标签: git jenkins


    【解决方案1】:

    您可以为 to 字段使用通用参数 ${env.To}

    并确保使用 loadproperties 创建此值

    sh '''
        echo To=$(get you commiter email) >> propsfile.txt
    '''
    
    script {
               properties = readProperties file: 'propsfile.txt'
               properties.each{ k, v -> env."${k}"="${v}" }  
           }
    

    【讨论】:

    • 所以它会从 propsfile.txt 中的 key、value 电子邮件地址列表中读取?
    • 是的,它会创建环境变量,以便您以后可以使用它
    猜你喜欢
    • 1970-01-01
    • 2015-09-25
    • 1970-01-01
    • 1970-01-01
    • 2018-12-17
    • 2014-02-23
    • 1970-01-01
    • 1970-01-01
    • 2011-04-11
    相关资源
    最近更新 更多