简体   繁体   English

使用代码使用新的 jenkins 管道 groovy 脚本构建 jenkins 作业

[英]Use code to build jenkins job with new jenkins pipeline groovy script

I have a jenkins pipeline, name is TEST-PIPELINE, then I changed jenkinsfile(pipeline config) locally, like:我有一个 jenkins 管道,名称是 TEST-PIPELINE,然后我在本地更改了 jenkinsfile(pipeline config),例如:

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                echo 'Building..'
            }
        }
        stage('Test') {
            steps {
                echo 'Testing..'
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploying....'
            }
        }
    }
}

I wonder to trigger a new job with new modified script above.我想知道用上面的新修改脚本触发新工作。

How to trigger new job with new pipeline code by using python or some code, instead web page?如何通过使用 python 或某些代码而不是 web 页面来使用新的管道代码触发新作业? I'd like to automatically to test new modified jenkinsfile, so need code to trigger that job with new file.我想自动测试新修改的 jenkinsfile,因此需要代码来用新文件触发该作业。 Thanks!谢谢!

If you are using Multi Branch Pipeline, you can configure build like this.如果您使用的是多分支管道,您可以像这样配置构建。 Then, when a new change is pushed in the branch build will be triggered.然后,当在分支构建中推送新的更改时,将被触发。

在此处输入图像描述

PS: Web Hooks should be also defined DOCUMENTATION PS:Web Hooks 也要定义DOCUMENTATION

I use Generic Webhook trigger plugin to run my pipeline when there is new commit in the repository.当存储库中有新提交时,我使用通用 Webhook 触发器插件来运行我的管道。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM