git - 使用 Jenkins 管道作业将 Jenkins 作业构建状态发布到 Gitlab 提交

标签 git jenkins gitlab jenkins-pipeline

我已经将我的 Gitlab CE 版本 9.3.5 与 jenkins 版本 2.60.1 集成在一起。

我能够使用 Gitlab webhook 触发构建,并使用 jenkins freestyle 作业将结果发布回提交。

我想知道如何使用 jenkins pipeline job 实现相同的效果,因为关于上述集成的每篇文章都适用于 jenkins freestyle job。

最佳答案

如果我遵循有关 Gitlab Jenkins plugin 的文档,您应该能够使用 gitlabCommitStatus 方法,该方法将发布之后声明的构建步骤的状态(这里是来自文档的示例):

node() {
    stage 'Checkout'
    checkout <your-scm-config>

    gitlabCommitStatus {
       <script that builds, tests, etc. your project>
    }
}

如果这还不够,您还可以使用 updateGitlabCommitStatus name: 'build', state: 'pending' 来更精确地控制您发送到 gitlab 实例的状态。

关于git - 使用 Jenkins 管道作业将 Jenkins 作业构建状态发布到 Gitlab 提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46342869/

相关文章:

java - Jenkins 在 Windows 虚拟驱动器上的 FileNotFound

docker - GitLab:无法注册运行者(使用正确的 token !) - 干净/最新的 docker install

javascript - 错误类型错误 : Cannot set property 'proceed' of undefined

javascript - 类型错误 : gitlab is not a function

git - Docker Webhook容器:应该运行脚本,但是脚本无法正确执行(仅回显有效)

git - Vim Fugitive : Gblame reblame options

git - 如何在 jenkins 管道代码中输入 git 凭据

git - 删除所有已经被压扁 merge 的本地分支

c# - roslyn 编译器未使用 msbuild 复制到 AspnetCompileMerge 文件夹

jenkins - 如何将加特林与 Jenkins 集成