У меня задание Jenkins Pipeline
определено в моем репо git как.
// File: deployment/jenkinsfiles/staging/Merge
@Library("my_shared_lib") _
import com.company.myteam.Constants
pipeline {
agent { label "common" }
triggers {
pollSCM("H/2 * * * *")
}
options {
buildDiscarder(logRotator(numToKeepStr: "50", artifactNumToKeepStr: "50"))
}
stages {
stage ("Staging Merge") {
steps {
script {
def config = new Constants().repoconfig
ansiColor("xterm") {
myteam.pipelines.stagingMerge(config)
}
}
}
}
}
post {
always {
cleanWs()
}
}
}
Затем я создал конфигурацию задания jenkins, как показано ниже.

Теперь, когда я проверяю Git Polling Log
его опрос shared-library
тоже.
Started on Feb 25, 2020 5:33:07 PM
Using strategy: Default
[poll] Last Built Revision: Revision 681f996e689bdeb9cfca2b167002b8ccd99590cb (origin/staging)
using credential github_username_with_token
> git --version # timeout=10
using GIT_ASKPASS to set credentials Github Service Account Username with token
> git ls-remote -h https://myuser@github.company.com/myteam/myrepo # timeout=10
Found 6 remote heads on https://myuser@github.company.com/myteam/myrepo
[poll] Latest remote head revision on refs/heads/staging is: 681f996e689bdeb9cfca2b167002b8ccd99590cb - already built by 53
Using strategy: Default
[poll] Last Built Revision: Revision e80628ec7c9dbc59decbc81a3b884dcaa963a8dc (refs/remotes/origin/master)
using credential github_username_with_token
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
> git config remote.origin.url https://myuser@github.company.com/myteam/jenkins-shared-libraries.git # timeout=10
Fetching upstream changes from https://myuser@github.company.com/myteam/jenkins-shared-libraries.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials Github Service Account Username with token
> git fetch --tags --progress https://myuser@github.company.com/myteam/jenkins-shared-libraries.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Polling for changes in
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
> git log --full-history --no-abbrev --format=raw -M -m --raw e80628ec7c9dbc59decbc81a3b884dcaa963a8dc..869b3a16e07d21a88d557f1857376bfed7717a6e # timeout=10
Всякий раз, когда я изменяю код в jenkins-shared-library
, начинается его сборка для задания.
Я пытался workaround
, указанный в https://issues.jenkins.io/browse/JENKINS-39615?focusedCommentId=280729&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment -280729 , но не повезло.
Я изменил pollSCM
на githubPush
, но это также срабатывает, когда Я изменяю в shared-library
.
Я пробовал решение, указанное в https://issues.jenkins-ci.org/browse/JENKINS-41497 как Ignore on push notifications
для githubPush()
, но все еще его запускающее задание.
До перехода на pipeline
у меня было freestyle
проект. Там, где есть раздел Управление исходным кодом , где мы можем определить ветвь, а githubPush()
прослушивал только эту ветвь.
При выборе типа проекта в качестве pipeline
отсутствует Раздел управления исходным кодом . Это может быть связано с прослушиванием всех событий pu sh.
По push
или poll
, я хочу ограничить запуск задания jenkins только при наличии изменений только на myrepo.git
.