By doing System.getenv() you're getting the environment of the Jenkins
master process.

The environment that will be used by any process run in the pipeline is
available through the built-in variable env.

Regards,
Daniel

On 20 Nov 2017 2:14 am, "red 888" <[email protected]> wrote:

In my pipeline I'm injecting aws credentials:


withCredentials([[$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: '89h9sfh8shf98shf98he9f8sf',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {

    sh 'printenv'

    echo myFunc.myMeth('blah','sdjlfkdf')
}


myFunc looks like this:


class myFunc {
    static Object myMeth (String param1, String param2){


        def env = System.getenv()
        //Print all the environment variables.
        env.each{
            println it
        }
    }}


Looking at the output of sh 'printenv' I see AWS_ACCESS_KEY_ID and
AWS_SECRET_ACCESS_KEY are injected. But when I try to echo back what envs
myFunc has access to I don't see those variables. Is this by design? Is
myFunc isolated and I need change its scope or something?

-- 
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/
msgid/jenkinsci-users/6dfaad11-29f5-4287-a0a0-a16a2373ecd4%40googlegroups.
com
<https://groups.google.com/d/msgid/jenkinsci-users/6dfaad11-29f5-4287-a0a0-a16a2373ecd4%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAO37hbjxXNv7NtZb%3DvLo-sZ-uh3%2Bv_1%2B6Ch4S9oD4j1dCtq9dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to