Thank you Stephen! After fixing typos it worked for me from Script Console:

for (f in 
Jenkins.instance.getAllItems(jenkins.branch.MultiBranchProject.class)) {
  if (f.parent instanceof jenkins.branch.OrganizationFolder) {
    // managed by org folder, leave alone
    continue;
  }
  // addTrigger will replace an existing one
  f.addTrigger(new 
com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger("1d"));
}

Maybe in the future I'll be able to somehow incorporate this code into a 
JobDSL seed job to fully automate the definition of my multibranch job.

On Thursday, July 27, 2017 at 2:59:23 PM UTC+3, Stephen Connolly wrote:
>
> Cannot be done from a Jenkinsfile.
>
> You can do via the groovy console with something like
>
> for (var f in 
> Jenkins.instance.getAllItems(jenkins.branch.MultiBranchProject.class) {
>   if (f.parent instanceof jenkins.branch.OrganizationFolder) {
>     // managed by org folder, leave alone
>     continue;
>   }
>   // addTrigger will replace an existing one
>   f.addTrigger(new 
> com.cloudbees.hudson.plugins.folder.computedPeriodicFolderTrigger("1d"));
> }
>
> On 26 July 2017 at 20:03, Ramanathan Muthaiah <[email protected] 
> <javascript:>> wrote:
>
>> On Thursday, July 27, 2017 at 5:12:55 AM UTC+5:30, Yuri Govorushchenko 
>> wrote:
>>>
>>> Hello,
>>>
>>> I have a *Multibranch Pipeline* job and would like to programatically 
>>> set its property found in UI at *Scan Multibranch Pipeline Triggers -> 
>>> Periodically if not otherwise run -> Interval*. Ideally I'd like to do 
>>> it in a scripted *Jenkinsfile* used to define the job. Maybe it can be 
>>> somehow achieved via properties step? It seems to be a property of 
>>> CloudBees Folders Plugin 
>>> <https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin> but 
>>> I couldn't figure out how it can be modified without a UI.
>>>
>>
>> We are on the same boat . . . would be interested to know how this can be 
>> done; if you hit upon the solution, pls do share here.
>>
>> /Ram 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/ace70cd8-afa6-4966-a82c-e449cad3eeef%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/ace70cd8-afa6-4966-a82c-e449cad3eeef%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8cf5771d-a47a-461a-9668-dd66e3a327a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to