So this is a problem for me because the APIs I'm using in the groovy class 
are looking for OS level environment variables.

Is there any way to set these variables with jenkins?

On Tuesday, November 28, 2017 at 5:54:37 PM UTC-5, mpapo - Michael 
Pailloncy wrote:
>
> Pipeline environment variables are not stored at the OS level. That's why 
> you are not able to get them using *System.getenv() *(which only list OS 
> level environment variables).
> But you should be able to retrieve them like any other classical 
> environment variables : with the "${MyVar}" syntax inside your shared lib 
> class.
>
> Hopefully it helps.
>
> Michaƫl
>
> 2017-11-28 22:30 GMT+01:00 red 888 <fakemai...@gmail.com <javascript:>>:
>
>> My pipeline is using the environment directive to set an environment var 
>> and then calls a groovy class:
>>
>> def call(int blah) {
>>
>>     pipeline {
>>         agent any
>>
>>         environment {
>>             MyVar = credentials('djsjflsjfljsf')
>>         }
>>
>>         stages {
>>             stage('Stage ONE') {
>>                 steps {
>>                     echo test.methodA()
>>
>>             ....
>>
>>
>>
>> But from in my groovy class I don't see those environment variables:
>>
>> // vars/test.groovy
>>
>>
>> class test implements Serializable {
>>     static methodA (){
>>
>>     def env = System.getenv()
>>     return env.dump()
>>     //return ['powershell', 'ls env:'].execute().text
>>
>> }
>>
>>  
>> env.dump() and listing envs from the shell from inside the class doesn't 
>> show those variables I added in the environment directive. Can I change the 
>> scope of the class to give it access to these environment vars?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-use...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/87b6e2b0-ed9a-4ede-b22c-3b06761345e1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/87b6e2b0-ed9a-4ede-b22c-3b06761345e1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/6e7e1b97-7b9c-404f-9597-8577eb739b96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to