Try the Groovy Postbuild Plugin
You could also use the build step "Execute system Groovy script"
torsdag 9. juni 2016 08.05.39 UTC+2 skrev kumar naresh følgende:
>
>
> Hi Sverre Moe,
>
>
> thanks that works really good.
>
> I'm actually trying to add build step to execute shell existing jenkins
> job using groovy script, let me know if there any steps to do so.
>
> Regareds,
> kumar.
> On Monday, June 6, 2016 at 7:02:47 PM UTC+5:30, Sverre Moe wrote:
>>
>> import com.cloudbees.hudson.plugins.folder.Folder
>>
>> def jenkinsInstance = jenkins.model.Jenkins.getInstance()
>> def newProject = jenkinsInstance.createProject(Folder.class,
>> "my-folder-project")
>>
>>
>> mandag 6. juni 2016 15.17.13 UTC+2 skrev kumar naresh følgende:
>>>
>>> Hi Daniel,
>>>
>>> could you please let me know exactly how to create a jenkins folder job
>>> using groovy script.
>>>
>>> Regards,
>>> Naresh.
>>>
>>> On Friday, August 21, 2015 at 12:42:40 AM UTC+5:30, Daniel Serodio wrote:
>>>>
>>>> We use this Groovy script to move jobs to folders, maybe you can use it
>>>> as a starting point for your needs:
>>>>
>>>> ###############################
>>>> def FOLDER_NAME = 'Destination folder'
>>>> def JOB_REGEX = 'Regex to match your jobs'
>>>>
>>>> import jenkins.*
>>>> import jenkins.model.*
>>>> import hudson.*
>>>> import hudson.model.*
>>>>
>>>> jenkins = Jenkins.instance
>>>>
>>>> def folder = jenkins.getItemByFullName(FOLDER_NAME)
>>>> if (folder == null) {
>>>> println "ERROR: Folder '$FOLDER_NAME' not found"
>>>> return
>>>> }
>>>>
>>>> jenkins.items.grep { it.name =~ "${JOB_REGEX}" }.each { job ->
>>>> println "Moving '$job.name' to '$folder.name'"
>>>> Items.move(job, folder)
>>>> }
>>>> ###############################
>>>>
>>>> Regards,
>>>> Daniel Serodio
>>>>
>>>>
>>>> On Saturday, August 15, 2015 at 3:19:24 AM UTC-3, Stephen Connolly
>>>> wrote:
>>>>>
>>>>> What I said:
>>>>>
>>>>> 1. You can use a groovy script right now. Will do exactly what you
>>>>> need. Some research required.
>>>>>
>>>>> 2. Oh look some synchronicity, I happen to have just been working on
>>>>> some stuff that would do this for a bigger set of problems... Sadly the
>>>>> stuff I was working on is for our paid product
>>>>>
>>>>> 3. The OSS should have a CLI command too... I think it does, but if I
>>>>> am wrong, adding a CLI command for the OSS plugin is something on our
>>>>> backlog, so we will get to it.
>>>>>
>>>>> I mentioned #2 not as a plug but more as a "oh, if you did happen to
>>>>> also be one of our customers"... Apologies if it read differently.
>>>>>
>>>>> -Stephen
>>>>>
>>>>> On Saturday, August 15, 2015, Vanetta Floyd <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Thanks...not interested in commercials for that product. I'm
>>>>>> interested in what the open source community has to say.
>>>>>>
>>>>>> Will all people asking questions going forward be spammed with plugs
>>>>>> for that product?
>>>>>> On Aug 14, 2015 10:48 AM, "VFloyd" <[email protected]> wrote:
>>>>>>
>>>>>>> Any ideas on how to move more than one job at a time into a folder?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thursday, August 6, 2015 at 1:45:47 PM UTC-7, Daniel Laird wrote:
>>>>>>>>
>>>>>>>> All,
>>>>>>>>
>>>>>>>> I amusing the cloudbees plugin that creates folders.
>>>>>>>> I am now trying to move some jobs that are currently in a 'view'
>>>>>>>> into a folder.
>>>>>>>> I can easily query and list all the jobs in a view in groovy but I
>>>>>>>> am struggling to move the job into a folder.
>>>>>>>> I have tried various methods - if anyone has some example of doing
>>>>>>>> this it would be greatly appreciated.
>>>>>>>>
>>>>>>>> Dan
>>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>> the Google Groups "Jenkins Users" group.
>>>>>>> To unsubscribe from this topic, visit
>>>>>>> https://groups.google.com/d/topic/jenkinsci-users/doYddgacqTQ/unsubscribe
>>>>>>> .
>>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>>> [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/jenkinsci-users/e4cd1d42-0fba-4faf-a023-caab8b466a52%40googlegroups.com
>>>>>>>
>>>>>>> <https://groups.google.com/d/msgid/jenkinsci-users/e4cd1d42-0fba-4faf-a023-caab8b466a52%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/CAL40ccPVuPWnNeaRostT0uggh6PaOmwE3KUzTPN2mbdqvtX%2BvQ%40mail.gmail.com
>>>>>>
>>>>>> <https://groups.google.com/d/msgid/jenkinsci-users/CAL40ccPVuPWnNeaRostT0uggh6PaOmwE3KUzTPN2mbdqvtX%2BvQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent from my phone
>>>>>
>>>>
--
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/13521d94-cea4-407a-9714-30dcac578fa4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.