代码之家  ›  专栏  ›  技术社区  ›  thclpr

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

  •  0
  • thclpr  · 技术社区  · 7 年前

    目前我知道可以用 GitHub pull request builder plugin . 但从目前开始,我只在Jenkins上使用Github组织项目,因为我们拥有大量的存储库,所以可以通过声明性管道更改上下文消息吗?

    当前: enter image description here

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  1
  •   thclpr    7 年前

    解决方法:

        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