gpt4 book ai didi

Jenkins简单管道不是由github推送触发的

转载 作者:行者123 更新时间:2023-12-02 17:10:15 25 4
gpt4 key购买 nike

enter image description here我使用以下脚本创建了一个名为“pipelinejob”的 Jenkins 管道作业:

pipeline {
agent any

stages {

stage ('Setup'){
steps{
//echo "${BRANCH_NAME}"
echo "${env.BRANCH_NAME}"
//echo "${GIT_BRANCH}"
echo "${env.GIT_BRANCH}"
}
}
}
}
  1. 在“常规”下,我选择了“GitHub 项目”并以以下形式插入了我公司的 github:

https://github.mycompany.com/MYPROJECTNAME/MY_REPOSITORY_NAME/

  • 在“构建触发器”下,我选中了“GITScm 轮询的 GitHub Hook 触发器”

  • 我创建了一个名为“simplejob”的简单作业,其配置与 1) 和 2) 相同

  • 在我公司的 Github 中,我创建了一个像“jenkins_url/jenkins/github-webhook/”这样的 webhook

  • 我在“MY_REPOSITORY_NAME”的“mybranch”中提交了更改

  • 我的简单作业“simplejob”已触发并成功构建

  • 我的管道作业“pipelinejob”未触发

  • 在 Jenkins 日志中我看到以下内容:

  • Sep 12, 2019 2:42:45 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
    Poked simplejob

    与我的“管道工作”无关。

    您能否为我指出下一步要检查的内容的正确方向?

    附注我已成功手动执行“pipelinejob”

    最佳答案

    我为此浪费了两天的时间,因为之前的解决方案都不适合我。 :-(
    最终我在另一个论坛上找到了解决方案:
    问题是,如果您使用存储在 GitHub 中的 Jenkinsfile 以及项目源,则必须在 Jenkinsfile 本身中配置此触发器,而不是在 Jenkins 或项目配置中配置。
    因此,将如下所示的触发器 {} block 添加到您的 Jenkinsfile 中:

    pipeline {
    agent any
    triggers {
    githubPush()
    }
    stages {
    ...
    }
    }

    然后...

    • 将您的 Jenkinsfile 推送到 GitHub
    • 手动运行一个构建,让 Jenkins 了解您使用此触发器的意愿。
      您会注意到“GITScm 轮询的 GitHub hook 触发器”复选框最终将被选中!
    • 重新启动 Jenkins。

    下一次推送最终应该会触发自动构建!

    关于Jenkins简单管道不是由github推送触发的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57910427/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com