Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
borderStylesolid
titlePipeline Wrapper Workarounds
node('master') {
    TEST_KEY = ''

    wrap([$class: 'ConsulKVReadWrapper', reads: [[aclToken: '', apiUri: '', debugMode: 'ENABLED', envKey: 'test_key', hostUrl: '', key: 'test/test-key']]]) {
        echo env.test_key
        TEST_KEY = env.test_key
    }

    echo TEST_KEY
}

//or for a global var:

import groovy.transform.Field
@Field String TEST_KEY

node('master') {

    wrap([$class: 'ConsulKVReadWrapper', reads: [[aclToken: '', apiUri: '', debugMode: 'ENABLED', envKey: 'test_key', hostUrl: '', key: 'test/test-key']]]) {
        echo env.test_key
        TEST_KEY = env.test_key
    }

    echo TEST_KEY
}

node ('master') {
    echo TEST_KEY
}

//Use Wrapper to get multiple key/values

node ('master') {
    wrap([$class: 'ConsulKVReadWrapper', reads: [[aclToken: '', apiUri: '', debugMode: 'ENABLED', envKey: 'test_key', hostUrl: '', key: 'test/test-key'], [aclToken: '', apiUri: '', debugMode: 'ENABLED', envKey: 'test_key2', hostUrl: '', key: 'test/test-key'], [aclToken: '', apiUri: '', debugMode: 'ENABLED', envKey: 'test_key3', hostUrl: '', key: 'test/test-key']]]) {
    	echo env.test_key
    	echo env.test_key2
    	echo env.test_key3
	}
}

 

Image Removed