如何使用声明性管道更改多分支项目的上下文消息?

How to change context message on a multibranch project using declarative pipeline?

目前我知道可以使用 GitHub pull request builder plugin 更改上下文消息。但是由于目前,由于我们拥有大量的存储库,我只在 Jenkins 上使用 GitHub 组织项目,是否可以通过声明性管道更改上下文消息?

当前:

预计:

解决方法:

    pipeline {
    agent any
    stages {
        stage("Stage #1") {
            steps {
                sh 'ls'
                githubNotify gitApiUrl: 'https://github.mycompany.com/api/v3', context: 'something test', description: 'This commit is being built',  status: 'PENDING'
            }
        }
    }
    post {
        success {
          githubNotify gitApiUrl: 'https://github.mycompany.com/api/v3', context: 'something test', description: 'It works',  status: 'SUCCESS'
        }
        failure {
          githubNotify gitApiUrl: 'https://github.mycompany.com/api/v3', context: 'something test', description: 'This commit cannot be built',  status: 'FAILED'
        }
    }
}

使用的插件:https://github.com/jenkinsci/pipeline-githubnotify-step-plugin