Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git Jenkins轮询或推式触发器作业也会为共享库更改运行_Git_Jenkins_Push Notification_Jenkins Pipeline_Polling - Fatal编程技术网

Git Jenkins轮询或推式触发器作业也会为共享库更改运行

Git Jenkins轮询或推式触发器作业也会为共享库更改运行,git,jenkins,push-notification,jenkins-pipeline,polling,Git,Jenkins,Push Notification,Jenkins Pipeline,Polling,我有JenkinsPipelinejob在我的git回购协议中定义为 // File: deployment/jenkinsfiles/staging/Merge @Library("my_shared_lib") _ import com.company.myteam.Constants pipeline { agent { label "common" } triggers { pollSCM("H/2 * * * *") } opt

我有Jenkins
Pipeline
job在我的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轮询日志
它的轮询
共享库

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共享库
中更改代码时,它都会启动作业的构建

我尝试了
解决方法
但没有成功

我将我的
pollSCM
更改为
githubPush
,但在
共享库中更改时也会触发此操作

我尝试了
githubPush()的
Ignore-on-push通知中给出的解决方案,但仍然是它的触发任务

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

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


通过
push
poll
,我想限制我的jenkins作业仅在
myrepo.git
上发生更改时触发。

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

如何办理登机手续?你能给出详细的配置吗?点击这个链接,参考“为你的项目创建Jenkins作业”一节。这仅仅是3个步骤。我尝试了
多分支
,问题是,每次推送都会触发所有分支。我需要限制到一个分支。不。如果配置正确。只有具有最新提交的分支才会自动触发。你是如何启动管道的?使用git webhook不是吗?git推送,暂时