jenkinsci / jenkinsci/parameterized-trigger-plugin
[JENKINS-45937] ArrayIndexOutOfBoundsException when $VARIABLE in project list contains comma
- Dominant language
- Java
- Stars
- 77
- Forks
- 174
- Avg merge
- 22h 27m
- Merged PRs (30d)
- 1
Description
Set an environment variable to PROJECTS=job1,job2
Add Trigger parameterized build on other projects step and set Projects to build to $PROJECTS
When running the job you will get an
11:14:36 java.lang.ArrayIndexOutOfBoundsException: 1
11:14:36 at hudson.plugins.parameterizedtrigger.BuildTrigger.perform(BuildTrigger.java:123)
11:14:36 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
11:14:36 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
11:14:36 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
11:14:36 at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)
11:14:36 at hudson.model.Run.execute(Run.java:1782)
11:14:36 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
11:14:36 at hudson.model.ResourceController.execute(ResourceController.java:97)
11:14:36 at hudson.model.Executor.run(Executor.java:405)
The offending code is
String[] projects = config.getProjects(build.getEnvironment(listener)).split(",");
String[] vars = config.getProjects().split(",");
for (int i = 0; i < projects.length; i++) {
if (vars[i].trim().contains("$")) {
One can easily see the arrays will be of different length when an enviorment variable contains the , character.
I don't understand why this logic is needed there though and the commit message only says "Trigger project by using parameters". sshelomentsev ?
---
Originally reported by jbochenski, imported from: ArrayIndexOutOfBoundsException when $VARIABLE in project list contains comma
Raw content of original issue
Set an environment variable to PROJECTS=job1,job2
Add Trigger parameterized build on other projects step and set Projects to build to $PROJECTSWhen running the job you will get an
11:14:36 java.lang.ArrayIndexOutOfBoundsException: 1
11:14:36 at hudson.plugins.parameterizedtrigger.BuildTrigger.perform(BuildTrigger.java:123)
11:14:36 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
11:14:36 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
11:14:36 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
11:14:36 at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)
11:14:36 at hudson.model.Run.execute(Run.java:1782)
11:14:36 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
11:14:36 at hudson.model.ResourceController.execute(ResourceController.java:97)
11:14:36 at hudson.model.Executor.run(Executor.java:405)The offending code is
String[] projects = config.getProjects(build.getEnvironment(listener)).split(",");
String[] vars = config.getProjects().split(",");
for (int i = 0; i < projects.length; i++) {
if (vars[i].trim().contains("$")) {One can easily see the arrays will be of different length when an enviorment variable contains the , character.
I don't understand why this logic is needed there though and the commit message only says "Trigger project by using parameters". sshelomentsev ?
Contributor guide
Assessment
This issue has not been assessed yet.