I make use of Matrix Jobs as I use a single codebase for multiple clients, with client specific settings coming from env files. They work pretty well, with some downsides.
One issue I’m facing is that the REST API simply doesn’t work. I have the correct credentials (I can successfully use them in a normal job) and I get the URL from the REST API page, having clicked through on one of the client axis
It gives and URL like the below, for building with parameters
http://myjenkins.com:8080/job/MatrixJob/Client=aClientName/buildWithParameters
It always gives a 500 status. Interestingly, the URL to use to initiate a build without parameters, does work.
Now here is what is confusing. The clients are setup as a user-defined axis, with a label of “Client” and there is a list of client names. This is used as a parameter itself when I trigger a build. I select a git branch and the clients I want to deploy to.
Clicking into an axis (a client) means I get the specific REST API URL for that client, which is fine, but I’d also want to use the base job URL, and pass the client names as a parameter for the axis, but that never works either
eg
http://myjenkins.com:8080/job/MatrixJob/buildWithParameters?Client=aClientName&branch=master
this is accepted and does indeed create a job, but the client param doesn’t work, and the job starts with no clients selected. I have the below error in the console
No such property: aClientName for class: groovy.lang.Binding
09:52:45 groovy.lang.MissingPropertyException: No such property: aClientName for class: groovy.lang.Binding
09:52:45 at groovy.lang.Binding.getVariable(Binding.java:63)
09:52:45 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:285)
09:52:45 at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375)
09:52:45 at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379)
09:52:45 at org.kohsuke.groovy.sandbox.impl.Checker$checkedGetProperty.callStatic(Unknown Source)
09:52:45 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
09:52:45 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:197)
09:52:45 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:233)
09:52:45 at Script1.run(Script1.groovy:1)
09:52:45 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runScript(GroovySandbox.java:195)
09:52:45 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:363)
09:52:45 at hudson.matrix.FilterScript.evaluate(FilterScript.java:45)
09:52:45 at hudson.matrix.FilterScript.apply(FilterScript.java:85)
09:52:45 at hudson.matrix.Combination.evalGroovyExpression(Combination.java:102)
09:52:45 at hudson.matrix.Combination.evalGroovyExpression(Combination.java:91)
09:52:45 at hudson.plugins.matrix_configuration_parameter.DefaultMatrixCombinationsParameterValue.combinationExists(DefaultMatrixCombinationsParameterValue.java:82)
09:52:45 at hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterMatrixBuildListener.doBuildConfiguration(MatrixCombinationsParameterMatrixBuildListener.java:57)
09:52:45 at hudson.matrix.listeners.MatrixBuildListener.buildConfiguration(MatrixBuildListener.java:70)
09:52:45 at hudson.matrix.DefaultMatrixExecutionStrategyImpl.filterConfigurations(DefaultMatrixExecutionStrategyImpl.java:188)
09:52:45 at hudson.matrix.DefaultMatrixExecutionStrategyImpl.run(DefaultMatrixExecutionStrategyImpl.java:123)
09:52:45 at hudson.matrix.MatrixBuild$MatrixBuildExecution.doRun(MatrixBuild.java:375)
09:52:45 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
09:52:45 at hudson.model.Run.execute(Run.java:1895)
09:52:45 at hudson.matrix.MatrixBuild.run(MatrixBuild.java:323)
09:52:45 at hudson.model.ResourceController.execute(ResourceController.java:101)
09:52:45 at hudson.model.Executor.run(Executor.java:442)
So, how do i fix this?
I would love to use pipelines, but no matter what I try, I am unable to create a pipeline job with a branch and user-defined axis parameter, where I can pick my git branch and a check list fo clients to build the job for.