- I have a new template, and when I want to create a new instance of it I am getting an error 500. No other trace in the logs.
- I have an existing template with multiple instances. I have updated the template and when I try to create a new instance of it I get an error 500.
- CloudBees Jenkins Enterprise (CJE)
- CloudBees Jenkins Enterprise - Managed Master (CJE-MM)
- CloudBees Jenkins Team (CJT)
- CloudBees Jenkins Platform - Client Master (CJP-CM)
- CloudBees Template Plugin. Different versions included in the Release Notes
There is no simple resolution for this issue, but in the following lines you will find the steps that you should be following in case that you want to understand what is happening.
The most probable cause for this error is a problem in the Groovy transformation code defined in your template. In order to get more information on what is happening, you will need to enable some loggers to get more insight on the error.
You can follow the document below in order to get more details on how to create a logger in Jenkins:
For this particular issue, you will need to include the following classes:
- com.cloudbees.hudson.plugins.modeling.impl.jobTemplate.JobTemplateDescriptor Level: All
- com.cloudbees.hudson.plugins.modeling.transformer.GroovyTemplateModelTransformer Level: All
After creating this logger you should try to create a new instance of the template, this will produce again the error 500 in our browser, but as you have enabled the loggers mentioned before, you will get additional information on the issue.
Analyzing the logs, you could find more details on the error, probably related to a non well formed resulting XML, as you can see below:
could not create /instance-x org.xml.sax.SAXParseException; lineNumber: xx; columnNumber: yy; The element type "xxxxx" must be terminated by the matching end-tag "</xxxx>". at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643) at com.cloudbees.hudson.plugins.modeling.transformer.GroovyTemplateModelTransformer.transform(GroovyTemplateModelTransformer.java:130) Caused: hudson.util.IOException2: Transformation failed. Groovy template didn't produce a well-formed XML:
In this case, you should need to review your transformation code and correct the error so that you could create new instances of your template.