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

In a Matrix job, Environment Script variables are not expanded in a Parameterized Build Trigger

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Jenkins 1.477
      Parametrized Trigger ...
      Environment Script ...
    • Similar Issues:

      Description

      Install Jenkins with both environment-script and parameterized-trigger plugins.

      This WORKS:

      Create a freestyle project.
      Check "Generate environment variables from script"
      Enter "echo Hello=World" into the script box.

      Add a post-build action "Trigger parameterized build on other projects"
      Select "Predefined parameters"
      Enter "Hello=$Hello" into the params box.

      Run the build. Note that the param to the next build is Hello=World.

      This DOES NOT WORK:

      Create a matrix project.
      Check "Generate environment variables from script"
      Enter "echo Hello=World" into the script box.
      Check the "Run only on parent" box.

      Add a post-build action "Trigger parameterized build on other projects"
      Select "Predefined parameters"
      Enter "Hello=$Hello" into the params box.

      Run the build. Note that the param to the next build is Hello=$Hello.

      Identical behavior if Run Only On Parent is checked or not, but I expect that this is a required option, because the post-build steps occur on the parent as well.

        Attachments

          Activity

          Hide
          sodabrew Aaron Stone added a comment -

          If this was fixed, I'm trying to find which release did it. JENKINS-15507 looks somewhat related, maybe.

          Show
          sodabrew Aaron Stone added a comment - If this was fixed, I'm trying to find which release did it. JENKINS-15507 looks somewhat related, maybe.
          Show
          kbriggs Kieron Briggs added a comment - Suggested fix: https://github.com/jenkinsci/environment-script-plugin/pull/1
          Hide
          ikedam ikedam added a comment -

          Removed parameterized-trigger from components.
          As the argued problem seems that injected parameters should be accessed from matrix parent. Not parameterized-trigger specific issue.

          Show
          ikedam ikedam added a comment - Removed parameterized-trigger from components. As the argued problem seems that injected parameters should be accessed from matrix parent. Not parameterized-trigger specific issue.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Kieron Briggs
          Path:
          src/main/java/com/lookout/jenkins/EnvironmentScript.java
          http://jenkins-ci.org/commit/environment-script-plugin/a207a9fbfa6e72a741bff8728258769916f32678
          Log:
          [FIXES JENKINS-14951] Set environment on matrix parent build

          If the build is a MatrixBuild, build wrappers are not invoked for the
          parent, only for the individual MatrixRuns. In order for the environment
          variables to be available to the parent (e.g. for post-build steps), we
          must inject the environment into the parent directly during the aggregator
          startBuild().

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kieron Briggs Path: src/main/java/com/lookout/jenkins/EnvironmentScript.java http://jenkins-ci.org/commit/environment-script-plugin/a207a9fbfa6e72a741bff8728258769916f32678 Log: [FIXES JENKINS-14951] Set environment on matrix parent build If the build is a MatrixBuild, build wrappers are not invoked for the parent, only for the individual MatrixRuns. In order for the environment variables to be available to the parent (e.g. for post-build steps), we must inject the environment into the parent directly during the aggregator startBuild().
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Dawid Malinowski
          Path:
          src/main/java/com/lookout/jenkins/EnvironmentScript.java
          http://jenkins-ci.org/commit/environment-script-plugin/226c76be8720ef6d4c769d0050f702e75a862c01
          Log:
          Merge pull request #5 from jenkinsci/pr1

          [FIXES JENKINS-14951] Set environment on matrix parent build

          Compare: https://github.com/jenkinsci/environment-script-plugin/compare/0431c27445c7...226c76be8720

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dawid Malinowski Path: src/main/java/com/lookout/jenkins/EnvironmentScript.java http://jenkins-ci.org/commit/environment-script-plugin/226c76be8720ef6d4c769d0050f702e75a862c01 Log: Merge pull request #5 from jenkinsci/pr1 [FIXES JENKINS-14951] Set environment on matrix parent build Compare: https://github.com/jenkinsci/environment-script-plugin/compare/0431c27445c7...226c76be8720

            People

            • Assignee:
              jorgenpt Jørgen Tjernø
              Reporter:
              sodabrew Aaron Stone
            • Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: