Home > Mobile >  Use code to build jenkins job with new jenkins pipeline groovy script
Use code to build jenkins job with new jenkins pipeline groovy script

Time:11-24

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!

CodePudding user response:

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.

enter image description here

PS: Web Hooks should be also defined DOCUMENTATION

CodePudding user response:

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

  • Related