Creating MultiJob with Maven SubJobs

340 views
Skip to first unread message

Kiren Pillay

unread,
Sep 4, 2015, 10:59:02 AM9/4/15
to job-dsl-plugin
Hi

I'm trying to create a Multi-job with the DSL plugin. The job reads a multmodule project, creates a maven job for each project. These jobs should all appear under one phase.

I can't get this to work though, it creates the Multijob and the project, but they're not linked (I don't see the project in the Multijob project).


def oldJob= jenkins.model.Jenkins.theInstance.getItem('AFT-3.0-Multijob')
if (oldJob!=null) oldJob.delete()

def url="svn://my-svn/za.co.za/automatedFunctionalTests/TEST_CASES/trunk"
        def svnCommand = "svn list --xml ${url}"

        def proc = svnCommand.execute()
        def myXml= proc.in.text
        def lists = new XmlSlurper().parseText(myXml)
        println "${myXml}- Ready to Slurp"


        def listOfEntities = lists.list.entry

        // iterate through branches

        count=0;

    multiJob("AFT-3.0-Multijob"){
            steps {
                phase('Run Regression Tests5','ALWAYS') {
   
                    listOfEntities.each(){
                       count++
                        def nextNode=it
                        def myKind=nextNode.@kind
                        println("Kind ${myKind}")

                        if (myKind=="dir" && count<2) {
                        
                            def branchName=nextNode.name.text()
                            println ("Found branchName to create job with ${branchName}")
                          def myNewJobName="AFT-3.0-Test ${branchName}"
                                delegate.mavenJob(myNewJobName) {
                                jdk('Java 8')
                                scm { svn("${url}/${branchName}") }
                                triggers { scm('*/15 * * * *') }
                                goals('clean test')
                                rootPOM('./pom.xml')
                            }
                           
                        }
                    }
                              
            }
        }
        }

Azul Inho

unread,
Sep 5, 2015, 7:42:17 AM9/5/15
to job-dsl-plugin

Kiren Pillay

unread,
Sep 7, 2015, 2:52:13 AM9/7/15
to job-dsl...@googlegroups.com

Thanks Azul. I'm interested in why my script doesn't work though. Can you spot any errors with it?

On 05 Sep 2015 1:42 PM, "Azul Inho" <ma...@azulinho.com> wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/SFzlsdYvt50/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/1b0e07e0-6b56-40dc-b3ae-fdc19a9ccfc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kiren Pillay

unread,
Sep 7, 2015, 4:50:58 AM9/7/15
to job-dsl-plugin
Ok, it seems you have to create the jobs in a separate operation, then add the jobs to the Multijob but make sure to use job and not the specific job.

ie.   delegate.job(myNewJobName)
instead of
  delegate.mavenJob(myNewJobName)

Thanks


On Monday, 7 September 2015 08:52:13 UTC+2, Kiren Pillay wrote:

Thanks Azul. I'm interested in why my script doesn't work though. Can you spot any errors with it?

On 05 Sep 2015 1:42 PM, "Azul Inho" <ma...@azulinho.com> wrote:
This is jinja2 but it builds a multijob
https://github.com/ClusterHQ/flocker/blob/master/jobs.groovy.j2

--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/SFzlsdYvt50/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.

Kiren Pillay

unread,
Sep 7, 2015, 11:29:53 AM9/7/15
to job-dsl-plugin
It seems I was incorrect.  It doesn't work, I've created the Maven Jobs and then created a Multijob referring to the created jobs and it gives the error:
 
"Type of item "AFT-3.0-Test ActiveSimSwap" does not match existing type, item type can not be changed"

Azul

unread,
Sep 7, 2015, 2:17:29 PM9/7/15
to job-dsl...@googlegroups.com

Can you try to rename your main multijob and child jobs so that they don't include white spaces and only include A-z and underscores?

--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/SFzlsdYvt50/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/e5521296-b877-4a80-b71d-d9ffa96dd3d4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages