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

PROMOTED_* variables not exposed to all promoted build actions

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • promoted-builds-plugin
    • None
    • Jenkins 1.606 on CentOS 6
      EnvInject plugin 1.90
      Parameterized Trigger plugin 2.26
      Promoted Builds plugin 2.21

      My aim is to access certain information created by the build being promoted. Specifically, version numbers which I want to use to create a release number that a parameterized build action or a build script action will use.

      It seems the environment of the build being promoted is not exposed directly to build actions, nor the builds triggered by the promotion, so my first thought was to use an "inject environment variables" action to load the environment saved by the build being promoted using a path deduced from the PROMOTED_* variables like this:

      ${JENKINS_HOME}/jobs/${PROMOTED_JOB_NAME}/builds/${PROMOTED_NUMBER}/injectedEnvVars.txt

      However, only JENKINS_HOME gets expanded, the other variables do not seem to be in scope. The only place I can see the PROMOTED_* variables appearing in scope is within a build script action.

      Other plugins affecting the environment do seem to allow their variables to appear in scope within configuration variables of actions, so I am wondering if this could be fixed in the promoted builds plugin? Or perhaps I just need to do something extra I don't know about.

      The "inject environment variables" action does not seem to offer any means to run a script, just the option to either to load a file, and/or to define properties directly in a text area. I've tried accessing the PROMOTED_* variables in both with no success.

      Alternatively, if the promoted builds plugin could provide some other way of accessing the environment of the build being promoted this might do, but it would seem most useful to users if the PROMOTED_* variables were more uniformly visible.

      Thanks!

          [JENKINS-27883] PROMOTED_* variables not exposed to all promoted build actions

          Joby Bett added a comment -

          I'm seeing the same problem, specifically in my case the "Create a formatted version number" from the Version Number Plug-In is not being passed through to the job specified in "Trigger parameterized build on other projects" in the actions section.

          I have BUILD_VER being set as the formatted version number and BUILD_VER=${BUILD_VER} as a predefined parameter.

          Joby Bett added a comment - I'm seeing the same problem, specifically in my case the "Create a formatted version number" from the Version Number Plug-In is not being passed through to the job specified in "Trigger parameterized build on other projects" in the actions section. I have BUILD_VER being set as the formatted version number and BUILD_VER=${BUILD_VER} as a predefined parameter.

          Joby Bett added a comment - - edited

          Ok I've been bashing my head on this all day, I can't get any environment variables to transfer to the triggered build other than the one specified in the Criteria section that I set at promotion time.

          I really need to be able to get at least the GIT_COMMIT variable, but preferably all of the job variables. I checked and they are all set correctly if I click the "Environment Variables" link on a specific build.

          Jenkins version 1.617
          Promote Build version 2.21
          Parameterized Trigger plugin 2.27

          Joby Bett added a comment - - edited Ok I've been bashing my head on this all day, I can't get any environment variables to transfer to the triggered build other than the one specified in the Criteria section that I set at promotion time. I really need to be able to get at least the GIT_COMMIT variable, but preferably all of the job variables. I checked and they are all set correctly if I click the "Environment Variables" link on a specific build. Jenkins version 1.617 Promote Build version 2.21 Parameterized Trigger plugin 2.27

          Conor Gahan added a comment -

          This issue is still unresolved and blocking my attempts to use environment variables in promotion actions, e.g. trigger JIRA workflow transition for issues included in the build when it is promoted based on the $JIRA_ISSUES environment variable from the base build.

          Is there any chance of someone looking into this?

          Conor Gahan added a comment - This issue is still unresolved and blocking my attempts to use environment variables in promotion actions, e.g. trigger JIRA workflow transition for issues included in the build when it is promoted based on the $JIRA_ISSUES environment variable from the base build. Is there any chance of someone looking into this?

          Tolu Onibiyo added a comment -

          I'm experiencing a similar issue. Can't use environment variables in promotion actions that were set during the build. In my specific case, I am doing a credential binding in my build action and passing those secret credentials into an environment variable (they're secret, so they're not visible). I then need to use those variables in my promotion action but Jenkins drops those variable values. I have also tried the what was recommended at https://jenkins.io/security/advisory/2016-05-11/ but no luck.

          Tolu Onibiyo added a comment - I'm experiencing a similar issue. Can't use environment variables in promotion actions that were set during the build. In my specific case, I am doing a credential binding in my build action and passing those secret credentials into an environment variable (they're secret, so they're not visible). I then need to use those variables in my promotion action but Jenkins drops those variable values. I have also tried the what was recommended at https://jenkins.io/security/advisory/2016-05-11/  but no luck.

          Oleg Nenashev added a comment -

          Sorry, over last months I had no time to work on the plugin, because I had to focus on the Jenkins core and other projects. I also have not been using this plugin on my own since 2016. So I have decided to unassign the issues so that there is no expectation that I work on them anytime soon.

          Currently the plugin is being transfered to another maintainer. Hopefully he will have some time to finish triaging of the issues and maybe to deliver some fixes. But, as in any community-driven project, everybody is welcome to propose pull requests and to contribute to the plugin's state.

          Oleg Nenashev added a comment - Sorry, over last months I had no time to work on the plugin, because I had to focus on the Jenkins core and other projects. I also have not been using this plugin on my own since 2016. So I have decided to unassign the issues so that there is no expectation that I work on them anytime soon. Currently the plugin is being transfered to another maintainer. Hopefully he will have some time to finish triaging of the issues and maybe to deliver some fixes. But, as in any community-driven project, everybody is welcome to propose pull requests and to contribute to the plugin's state.

          It has been a while since responsibility for this plugin was released. Is there a way to get this moved to the current plugin maintainer?
          I also still have issues getting parameters specific to a promotion exposed to further actions during a promotion process. The parameter is made but it is not populated.

          Brandon Johnson added a comment - It has been a while since responsibility for this plugin was released. Is there a way to get this moved to the current plugin maintainer? I also still have issues getting parameters specific to a promotion exposed to further actions during a promotion process. The parameter is made but it is not populated.

            Unassigned Unassigned
            wu_lee Nick S
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: