Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException: Illegal start index with ARTIFACT_NAME #3

Open
giorgio-v opened this issue May 29, 2012 · 7 comments · May be fixed by #12
Open

IndexOutOfBoundsException: Illegal start index with ARTIFACT_NAME #3

giorgio-v opened this issue May 29, 2012 · 7 comments · May be fixed by #12

Comments

@giorgio-v
Copy link

Hi Vincent,
I’m trying to setup the Jenkins plugin for RunDeck but I keep getting this error (please see below) when I set the job options to pkgname=$ARTIFACT_NAME{.*.deb}. I’m using Jenkins v 1.465 and plugin version 2.11

Notifying RunDeck...
ERROR: Publisher org.jenkinsci.plugins.rundeck.RundeckNotifier aborted due to exception
java.lang.IndexOutOfBoundsException: Illegal start index
at java.util.regex.Matcher.find(Matcher.java:576)
at org.jenkinsci.plugins.rundeck.RundeckNotifier.parseProperties(RundeckNotifier.java:233)
at org.jenkinsci.plugins.rundeck.RundeckNotifier.notifyRundeck(RundeckNotifier.java:162)
at org.jenkinsci.plugins.rundeck.RundeckNotifier.perform(RundeckNotifier.java:97)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:685)
at hudson.model.Build$RunnerImpl.post2(Build.java:162)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:632)
at hudson.model.Run.run(Run.java:1459)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)

@giorgio-v
Copy link
Author

Please note that the regular expression does contain the backslash. It has been swallowed by the github form.

@giorgio-v
Copy link
Author

Also, if I double escape with backslash, the Jenkins job runs fine but the resulting URL is completely wrong:

http://packages/deb/elpq/snapshot/%7B.*.deb%7D:

@jhmartin
Copy link

I'm seeing this too. Jenkins sees the artifact and is able to archive it, but selecting even artifact=$ARTIFACT_NAME{.*} returns the same error.

This is when using a maven build with the release:perform goal.

@jhmartin
Copy link

I have a suspicion the issue is:

        Matcher matcher = TOKEN_ARTIFACT_NAME_PATTERN.matcher(input);
        int idx = 0;
        while (matcher.find(idx)) {
[snip]
                    idx = matcher.start() + artifact.getFileName().length();

http://docs.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html seems to state that the matcher stores a copy of the string. If the result of the replacement results in an index that is longer than the entire original option input, the error will occur.

@jhmartin
Copy link

That was it!
while (matcher.find(idx)) { needs to be while (matcher.reset(input).find(idx)) {. PR incoming.

jhmartin pushed a commit to jhmartin/jenkins-rundeck-plugin that referenced this issue Aug 20, 2014
@jhmartin
Copy link

On a related note, Maven 'automatic artifact archiving' does not play well this this feature, instead one must configure it as a post-build action.

@jhmartin
Copy link

One additional note; the intent of the 'idx' logic isn't obvious -- matcher.find() acts as an iterator, so keeping track of where the last match ended shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants