简体   繁体   English

Jenkins脚本化管道可为每个新提交触发

[英]Jenkins scripted pipeline to trigger for every new commit

Below is the groovy syntax, that checkout develop branch on Build now (manual checkout). 下面是常规语法,即结账develop分支Build now (手动检出)。

node('node_1'){
    stage('dev-staging'){

        sh "cd ${WORKSPACE}"

        dir('xyz') {
            git branch: 'develop', 
                credentialsId: '71111-222-333-444-43333333a40',
                url: 'ssh://git@10.xx.xx.xx:2222/abc_project/xyz.git'
        }
        dir('def') {
            git branch: 'develop', 
                credentialsId: '71111-222-333-444-43333333a40',
                url: 'ssh://git@10.xx.xx.xx:2222/abc_project/def.git'
        }
    }
}

How to trigger checkout from develop branch, on every new commit on develop branch? 如何在develop分支上的每个新提交上触发从develop分支签develop automatic trigger but not manual trigger... 自动触发而不是手动触发...

You can use Webhook to trigger your job in Jenkins on new commit. 您可以使用Webhook在新提交时触发您在Jenkins中的工作。 Repeat same settings in gitlab for both xyz and def repos. 在gitlab中为xyz和def仓库重复相同的设置。

Jenkins Settings: Jenkins设置:

  1. Select Build Triggers try webhooks for push events. 选择“构建触发器”,尝试对推送事件进行Webhook。
  2. Select Build when a change is pushed to GitLab. GitLab webhook URL: http://yourjenkins/project/yourproject Build when a change is pushed to GitLab. GitLab webhook URL: http://yourjenkins/project/yourproject选择Build when a change is pushed to GitLab. GitLab webhook URL: http://yourjenkins/project/yourproject Build when a change is pushed to GitLab. GitLab webhook URL: http://yourjenkins/project/yourproject , copy job_url. Build when a change is pushed to GitLab. GitLab webhook URL: http://yourjenkins/project/yourproject ,复制job_url。
  3. Select push events. 选择推送事件。
  4. Click to Advanced button 单击高级按钮
  5. Find Allowed branches , select Filter branches by name and enter your branch name. 查找Allowed branches ,选择Filter branches by name然后输入分支名称。
  6. Save

Gitlab settings: - repeat same steps for xyz repo also. Gitlab设置: -对xyz repo也重复相同的步骤。

  1. Got to project integration settings: https://10.xx.xx.xx:2222/abc_project/def/settings/integrations . 转到项目集成设置: https://10.xx.xx.xx:2222 / abc_project / def / settings / integrations
  2. Enter into URL textbox job_url from Jenkins http://yourjenkins/project/yourproject , select Push events and press Add webhook 从Jenkins http://yourjenkins/project/yourproject输入URL文本框job_url,选择“ Push events ,然后按“ Add webhook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在提交分支时触发Jenkins管道? - How to trigger a Jenkins Pipeline on commit to a branch? 通过标记现有提交来触发Jenkins管道 - Trigger a Jenkins pipeline by tagging an existing commit 如何在 jenkins 多分支脚本管道中获取最新的 git 提交作者姓名或消息并在分支条件下使用 - How to get latest git commit author name or message in jenkins multibranch scripted pipeline and use under branch condition Jenkins Groovy(脚本)管道的Git轮询设置 - Git poll setup for Jenkins groovy (scripted) pipeline Jenkins管道:如果有新的提交,如何构建新工件 - Jenkins pipeline: How to build new artifacts only if has a new commit 触发Jenkins每2小时构建一次,但前提是有一个git提交 - Trigger Jenkins build every 2 hours but only if there was a git commit 当在同一个提交上推送新标签时,jenkins 不会触发构建 - jenkins does not trigger build when a new tag is pushed on the same commit 基于新的 GitHub 版本触发 Jenkins 构建或提交到 master 分支 - Trigger Jenkins build based on a new GitHub release or commit to the master branch 脚本化管道-Groovy语法可获取提交哈希或标签 - Scripted pipeline - Groovy syntax to grab commit hash or tag Jenkins脚本化管道为“ sh”构建步骤提供了GitHub SSH凭据 - Jenkins Scripted Pipeline supply GitHub SSH credentials for a 'sh' build step
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM