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

SimpleBuildStep to receive EnvVars

    Details

    • Similar Issues:

      Description

      SimpleBuildStep.perform needs to be given an EnvVars argument. Otherwise there is no way for an implementation to observe any local environment variable settings.

        Attachments

          Issue Links

            Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue is blocking JENKINS-23713 [ JENKINS-23713 ]
            Hide
            jglick Jesse Glick added a comment -

            A way for the step to set variables has also been requested. In a freestyle build I suppose this would simply set build variables. In a Pipeline build, not sure. Return a Map<String,String> from step?

            Show
            jglick Jesse Glick added a comment - A way for the step to set variables has also been requested. In a freestyle build I suppose this would simply set build variables. In a Pipeline build, not sure. Return a Map<String,String> from step ?
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 164012 ] JNJira + In-Review [ 181474 ]
            abayer Andrew Bayer made changes -
            Labels workflow pipeline workflow
            abayer Andrew Bayer made changes -
            Labels pipeline workflow pipeline
            Hide
            jglick Jesse Glick added a comment -

            In a freestyle build I suppose this would simply set build variables.

            Or via EnvironmentContributingAction, which is also not an option for a SimpleBuildStep due to JENKINS-29537.

            Show
            jglick Jesse Glick added a comment - In a freestyle build I suppose this would simply set build variables. Or via EnvironmentContributingAction , which is also not an option for a SimpleBuildStep due to JENKINS-29537 .
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-29537 [ JENKINS-29537 ]
            Hide
            jglick Jesse Glick added a comment -

            Without JENKINS-40070Run.getEnvironment cannot be used as a workaround.

            Show
            jglick Jesse Glick added a comment - Without  JENKINS-40070 ,  Run.getEnvironment cannot be used as a workaround.
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-40070 [ JENKINS-40070 ]
            jglick Jesse Glick made changes -
            Labels pipeline api pipeline
            Hide
            dbrooks David Brooks added a comment -

            Has there been any progress on this issue? This is blocking our company from updating our jobs to from Freestyle to Pipelines.

            Could the solution be as easy as doing what the old

            AbstractBuild getEnvironment()

            did which was holding onto an array that contained the RunListener's environments and NodeProperty's environments? And then in

            Run getEnvironment()

            we could add the environments from the array we gathered via 

            buildEnvironmentFor(this,env,listener);

            ?

            Show
            dbrooks David Brooks added a comment - Has there been any progress on this issue? This is blocking our company from updating our jobs to from Freestyle to Pipelines. Could the solution be as easy as doing what the old AbstractBuild getEnvironment() did which was holding onto an array that contained the RunListener's environments and NodeProperty's environments? And then in Run getEnvironment() we could add the environments from the array we gathered via  buildEnvironmentFor( this ,env,listener); ?
            Hide
            jglick Jesse Glick added a comment -

            This is blocking our company from …

            If you implement Step directly there are no restrictions.

            Could the solution be as easy as …

            No, that is not how it would work.

            Show
            jglick Jesse Glick added a comment - This is blocking our company from … If you implement Step directly there are no restrictions. Could the solution be as easy as … No, that is not how it would work.
            Hide
            dbrooks David Brooks added a comment -

            Jesse Glick The header of our class is

            public class IntrepidBuilder extends Builder implements SimpleBuildStep

            since we want our plugin to be compatible with both Freestyle and Pipelines. How might we update this to still allow the end user to use the "pipeline syntax generator" to call our build step?

            Show
            dbrooks David Brooks added a comment - Jesse Glick The header of our class is public class IntrepidBuilder extends Builder implements SimpleBuildStep since we want our plugin to be compatible with both Freestyle and Pipelines. How might we update this to still allow the end user to use the "pipeline syntax generator" to call our build step?
            Hide
            jglick Jesse Glick added a comment -

            Currently if you want to access environment variables, you cannot; you must implement Step instead.

            Show
            jglick Jesse Glick added a comment - Currently if you want to access environment variables, you cannot; you must implement Step instead.
            Hide
            jeremym Jeremy Marshall added a comment -

            How come the CHANGE_URL env variable is defined in multi-branch pipeline jobs (PRs) and this is accessible by adding to a publish/post step

            public boolean prepare(final Run<?, ?> run) {
            Map<String, String> env = null;
            try {
                env = getEnvironment(run, new LogTaskListener(LOGGER, Level.INFO));
                env.forEach((k, v) -> log("key: " + k + " value:" + v)); 
                .
                .
                .

            but GIT_URL and GIT_BRANCH is not?

            I'm trying to push from the warnings post step to the PR in Github. So far I can do it from a freestyle job and a PR in a multi branch pipeline but not in a standard pipeline, mainly because I can't derive the github url or github branch

             

            Show
            jeremym Jeremy Marshall added a comment - How come the CHANGE_URL env variable is defined in multi-branch pipeline jobs (PRs) and this is accessible by adding to a publish/post step public boolean prepare( final Run<?, ?> run) { Map< String , String > env = null ; try { env = getEnvironment(run, new LogTaskListener(LOGGER, Level.INFO)); env.forEach((k, v) -> log( "key: " + k + " value:" + v)); . . . but GIT_URL and GIT_BRANCH is not? I'm trying to push from the warnings post step to the PR in Github. So far I can do it from a freestyle job and a PR in a multi branch pipeline but not in a standard pipeline, mainly because I can't derive the github url or github branch  
            Hide
            jglick Jesse Glick added a comment -

            Jeremy Marshall CHANGE_URL is defined in branch-api. GIT_URL etc. are map keys in the return value of git / checkout, done in JENKINS-26100.

            Show
            jglick Jesse Glick added a comment - Jeremy Marshall CHANGE_URL is defined in branch-api . GIT_URL etc. are map keys in the return value of git / checkout , done in JENKINS-26100 .

              People

              • Assignee:
                Unassigned
                Reporter:
                jglick Jesse Glick
              • Votes:
                3 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated: