Does anyone know the correct method for setting job properties, specifically build triggers, from within a Jenkinsfile? (declarative pipeline script, in a multi-branch pipeline job).
For clarity I need to set specific build triggers for underlying jobs in a multibranch project. The triggers for the overarching multibranch project I can configure in the GUI.
Have tried methods listed here: Jenkins multi-branch pipeline and specifying upstream projects
Jenkins: Trigger Multi-branch pipeline on upstream change
How do I use Jenkins Pipeline properties step?
I get errors saying that since v0.8 I should be using the options step instead: https://jenkins.io/doc/book/pipeline/syntax/#declarative-pipeline
But I can't see any steps listed there that allow be to set build triggers within the options directive.
There is a config.xml in each of the branched job folders on the server, but I think this will be overwritten when I run the job again, as they sit under the multi branch job.
There is also an option to pass different properties into different branches (make exceptions for branches) but the only option I see there is to suppress SCM commits.
My overall aim with this is to try and make a single Jenkinsfile that dynamically allows all the underlying jobs in the multibranch project to be triggered by their dependent upstream builds.
Step 1: Work out how to set properties at all :)
Step 2: Populate each build dynamically with the upstream dependency properties, meaning they get kicked off when certain builds complete.
Question concerns step 1 only, step 2 is just where I'm trying to get to.
triggers { upstream(upstreamProjects: "pipeline-multi/trunk%2F/project_X", threshold: hudson.model.Result.SUCCESS) }
– Bothy