-2

该插件不提供声明性脚本。如何将其从脚本转换为声明?

网址:https ://github.com/jenkinsci/bitbucket-build-status-notifier-plugin

  ...
  stage 'Build'
    bitbucketStatusNotify(
      buildState: 'INPROGRESS',
      buildKey: 'build',
      buildName: 'Build',
      repoSlug: 'my-awesome-project',
      commitId: 'a83c709e9d514421ef614ef0a1117366c84c6304'      
    )
  try {
        myBuildFunction()
        bitbucketStatusNotify(
          buildState: 'SUCCESSFUL',
          buildKey: 'build',
          buildName: 'Build',
          repoSlug: 'my-awesome-project',
          commitId: 'a83c709e9d514421ef614ef0a1117366c84c6304'          
        )
  }catch(Exception e) {
          bitbucketStatusNotify(
          buildState: 'FAILED',
          buildKey: 'build',
          buildName: 'Build',
          buildDescription: 'Something went wrong with build!',
          repoSlug: 'my-awesome-project',
          commitId: 'a83c709e9d514421ef614ef0a1117366c84c6304'      
        )
    }
4

1 回答 1

0

快速查看插件代码表明示例中显示的 API 是构建步骤,因此您可以执行以下操作:

pipeline {
    agent any
    stages {
        stage('start') {
            steps {
                bitbucketStatusNotify(buildState: 'INPROGRESS' .... )
            }
        }
            .
            .
        stage('last') {
            steps {
                .
                .
                bitbucketStatusNotify(buildState: 'SUCCESSFUL' ... )
            }
        }
    }
    post {
        failure {
            bitbucketStatusNotify(buildState: 'FAILURE' ... )
        }
    }
}
于 2019-07-06T15:13:19.870 回答