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

Build number environment variable is not propagated when run inside a conditional build step

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When artifacts are copied through a conditional build setup, the build number environment variable (e.g. COPYARTIFACT_BUILD_NUMBER_...) does not get propagated (or is not visible) to the remaining build steps.

        Attachments

          Issue Links

            Activity

            Hide
            domi Dominik Bartholdi added a comment - - edited

            I think the issue is in the copyartifact plugin at CopyArtifact.onStarted() : https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java#L376-L379

            This method will not find a CopyArtifact.class in the BuildersList, as in our case the objects are wrapped in the 'org.jenkinsci.plugins.conditionalbuildstep.BuilderChain' and/or 'org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder'

            don't know how to fix this yet, therefore assigning it to the maintainer of the copyartifact plugin, maybe Jesse has an idea...

            Show
            domi Dominik Bartholdi added a comment - - edited I think the issue is in the copyartifact plugin at CopyArtifact.onStarted() : https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java#L376-L379 This method will not find a CopyArtifact.class in the BuildersList, as in our case the objects are wrapped in the 'org.jenkinsci.plugins.conditionalbuildstep.BuilderChain' and/or 'org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder' don't know how to fix this yet, therefore assigning it to the maintainer of the copyartifact plugin, maybe Jesse has an idea...
            Hide
            jglick Jesse Glick added a comment -

            I am not really the maintainer of this plugin (nor do I have any idea how to fix this bug with current Jenkins APIs).

            Show
            jglick Jesse Glick added a comment - I am not really the maintainer of this plugin (nor do I have any idea how to fix this bug with current Jenkins APIs).
            Hide
            darnaut Davi Arnaut added a comment -

            One way to fix it is to add an optional dependency on conditional-buildstep. If it is present, it should be possible to upcast and get the list of builders. In the mean time, I'm just adding the action to every build.

            Show
            darnaut Davi Arnaut added a comment - One way to fix it is to add an optional dependency on conditional-buildstep. If it is present, it should be possible to upcast and get the list of builders. In the mean time, I'm just adding the action to every build.
            Hide
            domi Dominik Bartholdi added a comment -

            Actually, i think this could be done with the current implementation of the conditional build step plugin.
            Do you wanna have a go with it?

            Show
            domi Dominik Bartholdi added a comment - Actually, i think this could be done with the current implementation of the conditional build step plugin. Do you wanna have a go with it?
            Hide
            darnaut Davi Arnaut added a comment -

            If asking me, no - please go ahead. Thanks!

            Show
            darnaut Davi Arnaut added a comment - If asking me, no - please go ahead. Thanks!
            Hide
            ikedam ikedam added a comment -

            I'm not sure why CopyArtifactRunListener#onStarted is required.
            Why don't it simply add EnvAction when it need that?

            Show
            ikedam ikedam added a comment - I'm not sure why CopyArtifactRunListener#onStarted is required. Why don't it simply add EnvAction when it need that?
            Show
            ikedam ikedam added a comment - https://github.com/jenkinsci/copyartifact-plugin/pull/47
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: ikedam
            Path:
            src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
            src/test/java/hudson/plugins/copyartifact/testutils/WrapperBuilder.java
            http://jenkins-ci.org/commit/copyartifact-plugin/6ccfac85e2f41a1152688408889849fb6c38f6b3
            Log:
            JENKINS-16028 JENKINS-18762 Added tests to reproduce JENKINS-16028 (environment variables are not set in maven prebuild), JENKINS-18762 (environment variables are not set when wrapped in another builder).

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: ikedam Path: src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java src/test/java/hudson/plugins/copyartifact/testutils/WrapperBuilder.java http://jenkins-ci.org/commit/copyartifact-plugin/6ccfac85e2f41a1152688408889849fb6c38f6b3 Log: JENKINS-16028 JENKINS-18762 Added tests to reproduce JENKINS-16028 (environment variables are not set in maven prebuild), JENKINS-18762 (environment variables are not set when wrapped in another builder).
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: ikedam
            Path:
            src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
            http://jenkins-ci.org/commit/copyartifact-plugin/581c57e7068bca29cdbfcdb15419ac7d8e3b1fa4
            Log:
            [FIXED JENKINS-16028] [FIXED JENKINS-18762] Adds EnvAction to hold COPYARTIFACT_BUILD_NUMBER_XXX when it's needed. It was added when a build starts and the build has copyartifact, which doesn't work for maven-project and copyartifacts wrapped in other builders.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: ikedam Path: src/main/java/hudson/plugins/copyartifact/CopyArtifact.java http://jenkins-ci.org/commit/copyartifact-plugin/581c57e7068bca29cdbfcdb15419ac7d8e3b1fa4 Log: [FIXED JENKINS-16028] [FIXED JENKINS-18762] Adds EnvAction to hold COPYARTIFACT_BUILD_NUMBER_XXX when it's needed. It was added when a build starts and the build has copyartifact, which doesn't work for maven-project and copyartifacts wrapped in other builders.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: ikedam
            Path:
            src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
            src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
            src/test/java/hudson/plugins/copyartifact/testutils/WrapperBuilder.java
            http://jenkins-ci.org/commit/copyartifact-plugin/c11b82688863105971e00cc27ad0501af436d903
            Log:
            Merge pull request #47 from ikedam/feature/JENKINS-16028_EnvActionWhenNeeded

            JENKINS-16028 JENKINS-18762 Adds EnvAction when it's needed

            Compare: https://github.com/jenkinsci/copyartifact-plugin/compare/22eb37c9763a...c11b82688863

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: ikedam Path: src/main/java/hudson/plugins/copyartifact/CopyArtifact.java src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java src/test/java/hudson/plugins/copyartifact/testutils/WrapperBuilder.java http://jenkins-ci.org/commit/copyartifact-plugin/c11b82688863105971e00cc27ad0501af436d903 Log: Merge pull request #47 from ikedam/feature/ JENKINS-16028 _EnvActionWhenNeeded JENKINS-16028 JENKINS-18762 Adds EnvAction when it's needed Compare: https://github.com/jenkinsci/copyartifact-plugin/compare/22eb37c9763a...c11b82688863
            Hide
            ikedam ikedam added a comment -

            Fixed in copyartifact 1.32.

            Show
            ikedam ikedam added a comment - Fixed in copyartifact 1.32.

              People

              • Assignee:
                ikedam ikedam
                Reporter:
                darnaut Davi Arnaut
              • Votes:
                2 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: