So, after seeing this thread
(https://groups.google.com/forum/#!topic/jenkinsci-dev/OG03cDc7Gew), I
guess this may not work at all in a SimpleBuildStep. That is really too
bad, as I was hoping to keep the plugin working the same between Freestyle
and Pipeline. I feel that being able to set run-level environment
variables, outside of a blocked-scope step. I have this working in the
wrapper, but it now I have to abandon my step approach for Pipeline builds.
-Jimmy
On Wednesday, 2 November 2016 20:52:16 UTC-4, Jimmy Ray wrote:
>
> In a Freestyle job where I use the Build Step portion of this plugin, I
> can set the ENV variable and get it via a shell call of:
>
> echo ${key}
>
> So, it just does not work in the Pipeline Build Step.
>
> -Jimmy
>
> On Wednesday, 2 November 2016 16:48:01 UTC-4, Jimmy Ray wrote:
>>
>> In a wrapper plugin that I wrote, I set and environment string like so:
>>
>> context.env(key, value);
>>
>> Where "context" is that which is passed in like so:
>>
>> @Override
>> public void setUp(Context context, Run<?, ?> run, FilePath filePath,
>> Launcher launcher, TaskListener
>> listener, EnvVars envVars) throws IOException,
>> InterruptedException {...
>>
>>
>> I am trying to do the same with a pipeline step plugin:
>>
>> final EnvVars environment = build.getEnvironment(listener); ...
>>
>>
>> environment.addLine(String.format("%s=%s", key, value));
>>
>> The wrapper works fine, and env.<key> works fine. However, the step is
>> not working. In the step I log:
>>
>> logger.println(String.format("Stored ENV variable (k,v): %s=%s", key,
>> environment.get(key)));
>>
>> So, in the logs I see:
>>
>> Stored ENV variable (k,v): test_key=42
>>
>>
>> However, when I use the echo call I see null for the ENV var at that key:
>>
>> echo env.test_key
>>
>> So, I assume I have to do something else to get the ENV variable into the
>> right environment to be used after the step call? Am I missing some kind
>> of scoping issue with steps?
>>
>> -Jimmy
>>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/84394d83-8569-49af-94ce-517064c34437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.