首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对于共享库的更改,Jenkins轮询或扣动触发器作业运行。

对于共享库的更改,Jenkins轮询或扣动触发器作业运行。
EN

Stack Overflow用户
提问于 2020-02-25 17:59:19
回答 1查看 1K关注 0票数 3

我在我的git中定义了Jenkins Pipeline工作。

代码语言:javascript
复制
// 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也是如此。

代码语言:javascript
复制
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中更改代码时,它的起始构建就会用于该作业。

我试过workaroundhttps://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 for githubPush()的解决方案,但仍然是它的触发工作。

在搬到pipeline之前,我有freestyle项目。其中有节源代码管理,我们可以在其中定义分支,而githubPush()只监听该分支。

当我们选择项目类型为pipeline时,没有源代码管理部分。可能是因为这个原因,它倾听所有的推事件。

通过pushpoll,我希望将jenkins的工作限制为只在myrepo.git上有更改时触发。

EN

回答 1

Stack Overflow用户

发布于 2020-02-26 15:58:27

我不知道如何在这个Task Type中修复它。但是,如果您可以切换到多分支管道。该任务类型解决了此问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60400663

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档