在Github push上触发工作流程-管道插件-多分支配置 [英] Trigger workflow on Github push - Pipeline plugin - Multibranch configuration

查看:118
本文介绍了在Github push上触发工作流程-管道插件-多分支配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在CD中使用带有多分支配置的管道插件. 我们已经签入了可以在git上运行的Jenkinsfile.

We are using the pipeline plugin with multibranch configuration for our CD. We have checked in the Jenkinsfile which works off git.

git url: "$url",credentialsId:'$credentials'

工作正常,但是当将更改推送到github时不会自动触发. 我已经正确设置了GIT Web挂钩.

The job works fine, but does not auto trigger when a change is pushed to github. I have set up the GIT web hooks correctly.

有趣的是,当我进入多分支作业的一个分支并单击查看配置"时,我看到未选中将更改推送到Github时生成".由于我无法修改作业的配置(因为它是从父级获取的),并且父级中没有相同的选项,因此无法对其进行检查.

Interestingly, when I go into a branch of the multibranch job and I click "View Configuration", I see that the "Build when a change is pushed to Github" is unchecked. There is no way to check it since I can not modify the configuration of the job (since it takes from parent) and the same option is not there in parent.

有什么办法解决此问题吗?

Any ideas how to fix this?

推荐答案

我找到了一种方法来检查复选框将更改推送到Github时进行构建".

I found a way to check the checkbox "Build when a change is pushed to Github".

这行成功了:

properties([pipelineTriggers([[$class: 'GitHubPushTrigger'], pollSCM('H/15 * * * *')])])

我认为需要进行轮询才能使其正常工作.如果不需要轮询,那就太好了.

I think the polling is needed to make it work. Would be nice if no polling is needed.

这是一个已实现此示例的Jenkinsfile示例:

Here's a Jenkinsfile example with this implemented:

#!/usr/bin/env groovy

node ('master'){
    stage('Build and Test') {
        properties([pipelineTriggers([[$class: 'GitHubPushTrigger'], pollSCM('H/15 * * * *')])])
        checkout scm
        env.PATH = "${tool 'Maven 3'}/bin:${env.PATH}"
        sh 'mvn clean package'
    }
}

这篇关于在Github push上触发工作流程-管道插件-多分支配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆