aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Rendina <rendinam@users.noreply.github.com>2019-03-21 12:38:13 -0400
committerGitHub <noreply@github.com>2019-03-21 12:38:13 -0400
commit362ed861198e0ff15bbf4df8e5c048ca20e975b4 (patch)
tree5cfc384cc755b931d56391b971d4acc30c9a7ce5
parentfd66dd6dcd026ff3cc0651bd3f5e83e3f1f84e8c (diff)
downloadjscu_refactor-362ed861198e0ff15bbf4df8e5c048ca20e975b4.tar.gz
Test secret injection (#42)
Provide default credentials property in JobConfig class Convert credential env var value to java string Remove display of env var values.
-rw-r--r--src/JobConfig.groovy2
-rw-r--r--vars/utils.groovy11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/JobConfig.groovy b/src/JobConfig.groovy
index 6411917..cd299b6 100644
--- a/src/JobConfig.groovy
+++ b/src/JobConfig.groovy
@@ -10,6 +10,8 @@ class JobConfig implements Serializable {
def enable_env_publication = false
def publish_env_on_success_only = true
+ def credentials = null
+
// Build retention control
def builds_to_keep = -1
diff --git a/vars/utils.groovy b/vars/utils.groovy
index 7b74187..8a7c00e 100644
--- a/vars/utils.groovy
+++ b/vars/utils.groovy
@@ -622,7 +622,6 @@ def expandEnvVars(config) {
// @param config BuildConfig object
def abortOnGstrings(config) {
config.env_vars.each { evar ->
- println(evar)
if (evar.getClass() == org.codehaus.groovy.runtime.GStringImpl) {
msg = "Immediate interpolation of variables in the 'env_vars'" +
" list is not supported and will probably not do what" +
@@ -689,6 +688,16 @@ def run(configs, concurrent = true) {
// Loop over config objects passed in handling each accordingly.
buildconfigs.eachWithIndex { config, index ->
+ // Make any requested credentials available to all build configs
+ // in this job via environment variables.
+ if (jobconfig.credentials != null) {
+ jobconfig.credentials.each { cred_id ->
+ withCredentials([string(credentialsId: cred_id, variable: 'cred_id_val')]) {
+ config.env_vars.add("${cred_id}=${cred_id_val}".toString())
+ }
+ }
+ }
+
def BuildConfig myconfig = new BuildConfig() // MUST be inside eachWith loop.
myconfig = SerializationUtils.clone(config)