puzzle / jenkins-pipeline-shared-libraries

Shared functionality for Jenkins Pipeline Groovy scripts.
GNU General Public License v3.0
10 stars 13 forks source link

Oc env fix #43

Closed chrira closed 2 years ago

chrira commented 2 years ago

ctx.ensureOcInstallation() did not work when PATH var was defined in root environment {....} Env vars from root environment {....} can not be changed. Only using withEnv(){...} can change those vars.

I changed the oc commands using that method.

Attention: new is a check for setEnv in JenkinsPipelineContext. This would make the pipeline fail if a env var can not be changed.

    void setEnv(String name, String value) {
        script.env[name] = value

        if (script.env[name] != value) {
            script.error("""
setEnv of ${name} failure!
Variables defined inside 'environment {...}' cannot be overwritten!
Use 'withEnv(...) {...}' instead.""")
        }
    }

Is this check a good idea?