简体   繁体   中英

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:

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? I'd like to automatically to test new modified jenkinsfile, so need code to trigger that job with new file. 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

I use Generic Webhook trigger plugin to run my pipeline when there is new commit in the repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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