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

Post build task plugin: Passing arguments does not work as documented

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • postbuild-task-plugin
    • None
    • Jenkins ver. 1.454
      Windows

      The plugin info says:

      References %1, .. %n are allowed, and will be replaced by the groups matched by the Regex. %0 is the whole match.

      The documentation says:

      If the text is "Total time: (\d+)" and the script is "script.sh", then if the log contains a line "Total time: 10", the "script.sh 4" will be called.

      Neither works. When using %0, %1 etc., %0 becomes the path to a temporary batch file that seems to be used to call the script, e.g., C:\Users\<User>\AppData\Local\Temp\hudson2844785260200969554.bat.

          [JENKINS-17268] Post build task plugin: Passing arguments does not work as documented

          This functionality doesn't work on Linux and OS X either. Group captures are not available as script arguments. Example:

          Regular Expression (?m)^.*: warning: (Incomplete '.+' bundle copy detected.)$
          Script echo "Info: Post Build Task did detect a recoverable error:\n\t${1}"

          Francis Labrie added a comment - This functionality doesn't work on Linux and OS X either. Group captures are not available as script arguments. Example: Regular Expression (?m)^.*: warning: (Incomplete '.+' bundle copy detected.)$ Script echo "Info: Post Build Task did detect a recoverable error:\n\t${1}"

          Shaun M added a comment - - edited

          This looks like the problematic block to me, though I'm not a Java person.

            for(int index = 0; index < matches.size(); index++) {
              script = script .replace("%" + index, matches.get(index));
            }
          

          Note the space between script and .replace(...)

          edit: this snippet is from https://svn.jenkins-ci.org/trunk/hudson/plugins/postbuild-task/src/main/java/hudson/plugins/postbuildtask/PostbuildTask.java

          Shaun M added a comment - - edited This looks like the problematic block to me, though I'm not a Java person. for(int index = 0; index < matches.size(); index++) { script = script .replace("%" + index, matches.get(index)); } Note the space between script and .replace(...) edit: this snippet is from https://svn.jenkins-ci.org/trunk/hudson/plugins/postbuild-task/src/main/java/hudson/plugins/postbuildtask/PostbuildTask.java

          Gerold Broser added a comment -

          @sm_uc: The space is not a problem in Java.

          And the code is on GitHub now.

          Gerold Broser added a comment - @ sm_uc : The space is not a problem in Java. And the code is on GitHub now.

          Kyle Hamlin added a comment -

          Has anyone been able to address this issue?

          Kyle Hamlin added a comment - Has anyone been able to address this issue?

          Laurence Reading added a comment - - edited

          Yes it's been fixed in the latest github commit. The problem is that the current version never calls matcher.find() when doing the group replacement.

          Here is the commit https://github.com/jenkinsci/postbuild-task-plugin/commit/fe0572ac3ebedf471594dcc80df0d7ca05959c4c

          Is it possible to get this commit into the Jenkins repo?

          Edit: ah I see, it failed build https://jenkins.ci.cloudbees.com/job/plugins/job/postbuild-task-plugin/1

          Laurence Reading added a comment - - edited Yes it's been fixed in the latest github commit. The problem is that the current version never calls matcher.find() when doing the group replacement. Here is the commit https://github.com/jenkinsci/postbuild-task-plugin/commit/fe0572ac3ebedf471594dcc80df0d7ca05959c4c Is it possible to get this commit into the Jenkins repo? Edit: ah I see, it failed build https://jenkins.ci.cloudbees.com/job/plugins/job/postbuild-task-plugin/1

          Laurence Reading added a comment - Fixed in this PR https://github.com/jenkinsci/postbuild-task-plugin/pull/1

            Unassigned Unassigned
            marco_eckstein Marco Eckstein
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: