'Will Jenkins jobs on same nodet override or overwritte eachother environment variables?

I just can't find a definitive answer for this, documentation or otherwise.

Let's say I have 1 Jenkins agent/node executing a job and is using an environment variable:

pipeline {
    agent 'foo'
    stages {
        stage('Foo stage') {
            steps {         
                // BUILD_ID because it's different for each job
                withEnv(["myVar=$BUILD_ID"]) {
                    bat 'ECHO %myVar%'
                }
            }
        }
    }
}

I'm worried that in case I start multiple execution of this job on node 'foo' that some job might print the wrong thing because its env var is edited by some other job running at the same time.

I messed around with sleep trying to reproduce this issue but was not able to. Unfortunatly, this is not a good enough assurance that this can not happen.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source