jenkinshudsonjenkins-agent

Create new variable on Jenkins agent


I using Jenkins 2.252 and Jenkins agent on Windows host.

I want to create a new environment variable on the agent, using existing variable WORKSPACE.

But all my attempts are in vain. I have tried:

${WORKSPACE}

${env.WORKSPACE}

${env:WORKSPACE}

%WORKSPACE%

I really don't understand where is my mistake :(


Solution

  • Maybe the dollar symbol? Following works for me...

    node () {
        stage ('New environment variable')
        {
            println (env.WORKSPACE)
            env.NEWVAR = env.WORKSPACE
        }
        stage ('Still there?')
        {
            println (env.NEWVAR)
        }
    }