简体   繁体   中英

Env var returning null in path

I have set up to ENV Vars (Ubuntu 14.04)

CERT_PATH=/home/ubuntu/certs/developer.cert.co.uk.pem
CA_PATH=/home/ubuntu/certs/ca.pem

I am then grabbing those values in a JS script

var certPath = process.env.CERT_PATH;
var caPath = process.env.CA_PATH;

But I am stumped as to why one of the vars return null in the path:

-- console log here
CERT Path: null/certs/developer.cert.co.uk.pem
CA Path: /home/ubuntu/certs/ca.pem

What I don't understand is the same setup on OSX does not have this issue.

Though I cannot explain why i was getting null in my path, using the withEnv block around the relevant piece of my pipeline was what i ended up doing.

I normally do this but thought i could set the ENV var globally and be able to read from that without the need to so this, but seems to not be the case

withEnv(["CA_PATH=/home/ubuntu/certs/ca.pem", "CERT_PATH=/home/ubuntu/certs/developer.cert.co.uk.pem"]) {
 try {
   sh '''#!/bin/bash -l
         run tests
      '''
     TESTS = 'success'
 } catch (Exception err) {
     TESTS = "failure"
 } 
}

In the pipeline groovy script simply use env.CERT_PATH = /home/ubuntu/certs/developer.cert.co.uk.pem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM