在Jenkins文件中使用脚本语法时不会触发多分支作业
我有一个多分支管道,有两个分支(产品回购分支)master和qac 两个分支机构(即master和qac)都有Jenkins文件 在Jenkins文件中使用声明性语法时,作业会在git push上触发 下面是声明性文件在Jenkins文件中使用脚本语法时不会触发多分支作业,jenkins,multibranch-pipeline,Jenkins,Multibranch Pipeline,我有一个多分支管道,有两个分支(产品回购分支)master和qac 两个分支机构(即master和qac)都有Jenkins文件 在Jenkins文件中使用声明性语法时,作业会在git push上触发 下面是声明性文件 library( identifier: 'jenkins-library@master', retriever: modernSCM( [ $class: 'GitSCMSource', remote: 'https://github.c
library(
identifier: 'jenkins-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/ABC/Jenkins-CommonLib.git',
credentialsId: '2023203e3-a0da-445c-ab1c-1d26a416e3f8'
]
)
)
properties([pipelineTriggers([githubPush()])])
pipeline {
agent any
stages {
stage('Stage 1') {
steps {
script {
echo 'Stage 1'
}
}
}
}
}
library(
identifier: 'jenkins-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/ABC/Jenkins-CommonLib.git',
credentialsId: '20860d33-a0da-445c-ab1c-1d26a416e3f8'
]
)
)
properties([pipelineTriggers([githubPush()])])
node {
serviceAppBuild{}
}
但是,当使用脚本化的jenkins文件时,不会在git push上触发作业,但jenkins会收到push事件(可在jenkins日志中找到)
下面是脚本化的Jenkins文件
library(
identifier: 'jenkins-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/ABC/Jenkins-CommonLib.git',
credentialsId: '2023203e3-a0da-445c-ab1c-1d26a416e3f8'
]
)
)
properties([pipelineTriggers([githubPush()])])
pipeline {
agent any
stages {
stage('Stage 1') {
steps {
script {
echo 'Stage 1'
}
}
}
}
}
library(
identifier: 'jenkins-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/ABC/Jenkins-CommonLib.git',
credentialsId: '20860d33-a0da-445c-ab1c-1d26a416e3f8'
]
)
)
properties([pipelineTriggers([githubPush()])])
node {
serviceAppBuild{}
}
ServiceAppBuild是共享库中的一个groovy文件,实际上包含管道阶段
如何使用脚本文件触发构建