Dim*_*alt 7 github jenkins jenkins-pipeline github-webhook
在此处输入图像描述我使用以下脚本创建了一个名为“pipelinejob”的 jenkins 管道作业:
pipeline {
agent any
stages {
stage ('Setup'){
steps{
//echo "${BRANCH_NAME}"
echo "${env.BRANCH_NAME}"
//echo "${GIT_BRANCH}"
echo "${env.GIT_BRANCH}"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
1)在General下,我选择了“GitHub项目”,并在表格中插入了我公司的github:
https://github.mycompany.com/MYPROJECTNAME/MY_REPOSITORY_NAME/
2)在构建触发器下,我已经检查了“GitHub hook trigger for GITScm polling
3) 我创建了一个名为“simplejob”的简单作业,其配置与 1) 和 2) 相同
4) 在我公司的 Github 中,我创建了一个类似“jenkins_url/jenkins/github-webhook/”的 webhook
5)我在“MY_REPOSITORY_NAME”中的“mybranch”中进行了更改
6)我的简单作业“simplejob”被触发并成功构建
7)我的管道作业“pipelinejob”没有被触发
8) 在 Jenkins 日志中,我看到以下内容:
Sep 12, 2019 2:42:45 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Poked simplejob
Run Code Online (Sandbox Code Playgroud)
没有关于我的“pipelinejob”。
您能否为我指出下一步要检查的正确方向?
PS我已经成功地手动执行了我的“pipelinejob”
Jea*_*ire 12
我浪费了两天的工作,因为以前的解决方案都不适合我。:-(
最后我在另一个论坛上找到了解决方案:
问题是,如果您使用存储在 GitHub 中的 Jenkinsfile 以及您的项目源,那么必须在 Jenkinsfile 本身中配置此触发器,而不是在 Jenkins 或项目中配置。
所以在你的 Jenkinsfile 中添加一个 triggers {} 块:
pipeline {
agent any
triggers {
githubPush()
}
stages {
...
}
}
Run Code Online (Sandbox Code Playgroud)
然后...
下一次推送应该最终触发自动构建!
在管道作业的左侧窗格中,单击GitHub Hook log。如果它显示“轮询尚未运行”,您将需要手动触发一次管道作业,然后 Jenkins 将其注册到接收钩子上。
此后,该作业应在 GitHub 推送事件上自动触发。
| 归档时间: |
|
| 查看次数: |
4147 次 |
| 最近记录: |