0
votes

Hey I'd like to programatically configure a Jenkins-Pipeline with a Pipeline-Job which you can find at: https://github.com/divramod/pipeline-testing/blob/master/cicd/jobs/master.jenkins

This runs fine. But now, i like to also programatically configure other parts of the pipeline and i dont know where to start. For example, i like to configure the github url of the repo, which i can do manually at:

enter image description here

I also like to check the Build Trigger automatically, but dont know where to search for the right groovy configuration commands: (as you can see here)

enter image description here

pipelineJob('master pipe') {
    displayName('Master pipe')

    logRotator {
        numToKeep(10)
        daysToKeep(30)
    }

    configure { project ->
        project / 'properties' / 'org.jenkinsci.plugins.workflow.job.properties.DurabilityHintJobProperty' {
            hint('PERFORMANCE_OPTIMIZED')
        }
    }

    definition {
        cpsScm {
            scm {
                git {
                    remote {
                        url('[email protected]:divramod/pipeline-testing.git')
                        credentials('jenkins')
                    }
                    branches('*/master')
                }
            }
            scriptPath('cicd/pipelines/master.jenkins')
        }
    }
}
1

1 Answers

1
votes

You can add following block inside pipelineJob instruction to add github project url.

 properties{
   githubProjectUrl("url to repo")
 }

To add triggers, you can explore dynamic DSL