Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38895

Job DSL fails to add new job

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • job-dsl-plugin
    • None
    • Jenkins 2.25, job-dsl-plugin 1.51

      I have DSL script that creates new job for every banch read from separate text file.
      Sometimes this job which processes DSL script fails to create new job defined in DSL.
      Job log indicates that new job creation succeeded:

      Existing items:
          ...
          GeneratedJob{name='GameON_feature-click_on_logo_opens_menu_android'}
          ...
      

      But it doesn't show in jenkins ui and job files are not created on disk.
      In jenkins log I found this error:

      INFO: createOrUpdateConfig for GameON_feature-click_on_logo_opens_menu_android
      Oct 11, 2016 10:25:17 AM javaposse.jobdsl.plugin.JenkinsJobManagement createNewItem
      WARNING: Error writing config for new item GameON_feature-click_on_logo_opens_menu_android.
      java.io.IOException: Failed to persist config.xml
      	at hudson.model.ItemGroupMixIn.createProjectFromXML(ItemGroupMixIn.java:297)
      	at jenkins.model.Jenkins.createProjectFromXML(Jenkins.java:3749)
      	at javaposse.jobdsl.plugin.JenkinsJobManagement.createNewItem(JenkinsJobManagement.java:533)
      	at javaposse.jobdsl.plugin.JenkinsJobManagement.createOrUpdateConfig(JenkinsJobManagement.java:148)
      	at javaposse.jobdsl.dsl.JobManagement$createOrUpdateConfig$5.call(Unknown Source)
      	at javaposse.jobdsl.plugin.InterruptibleJobManagement.createOrUpdateConfig(InterruptibleJobManagement.groovy:37)
      	at javaposse.jobdsl.dsl.JobManagement$createOrUpdateConfig$5.call(Unknown Source)
      	at javaposse.jobdsl.dsl.DslScriptLoader$_extractGeneratedJobs_closure4.doCall(DslScriptLoader.groovy:212)
      	at sun.reflect.GeneratedMethodAccessor2351.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at groovy.lang.Closure.call(Closure.java:414)
      	at groovy.lang.Closure.call(Closure.java:430)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
      	at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at javaposse.jobdsl.dsl.DslScriptLoader.extractGeneratedJobs(DslScriptLoader.groovy:203)
      	at javaposse.jobdsl.dsl.DslScriptLoader.this$2$extractGeneratedJobs(DslScriptLoader.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
      	at javaposse.jobdsl.dsl.DslScriptLoader$_runScriptsWithClassLoader_closure1.doCall(DslScriptLoader.groovy:84)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at groovy.lang.Closure.call(Closure.java:414)
      	at groovy.lang.Closure.call(Closure.java:430)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2068)
      	at org.codehaus.groovy.runtime.dgm$164.invoke(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader(DslScriptLoader.groovy:68)
      	at javaposse.jobdsl.dsl.DslScriptLoader.this$2$runScriptsWithClassLoader(DslScriptLoader.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
      	at javaposse.jobdsl.dsl.DslScriptLoader.runScripts(DslScriptLoader.groovy:44)
      	at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:327)
      	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      	at hudson.model.Build$BuildExecution.build(Build.java:205)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:162)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      	at hudson.model.Run.execute(Run.java:1720)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:401)
      Caused by: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
      java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
      	at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
      	at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:191)
      	at jenkins.util.xml.XMLUtils.safeTransform(XMLUtils.java:66)
      	at hudson.model.ItemGroupMixIn.createProjectFromXML(ItemGroupMixIn.java:274)
      	... 74 more
      Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:450)
      	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:403)
      	at org.xml.sax.helpers.NewInstance.newInstance(NewInstance.java:82)
      	at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:228)
      	... 77 more
      
      

      Restarting jenkins and running main DSL job again fixes this problem.

      DSL:

      def branches = []
      readFileFromWorkspace("branches.txt").eachLine { branches << it }
      
      branches.each {
          def branchName = it.replaceAll('\'', '')
          def jobName = "GameON_${branchName.substring(7)}_android".replaceAll('/', '-')
          job(jobName) {
              displayName("GameON ${branchName}")
              ...
          }
          if (!jenkins.model.Jenkins.instance.getItemByFullName(jobName)) {
              queue(jobName)
          }
      }
      

            daspilker Daniel Spilker
            andbtk Andrius Butkevicius
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: