詹金斯档案
node {
checkout scm;
def config = readFile 'subdir/file'
}
pipeline {
agent any
environment {
tgt = "${config.tgt}" <---- config is not available
}
}
我收到错误
groovy.lang.MissingPropertyException: No such property: config for class: groovy.lang.Binding
那么,如何确保看到配置变量?
旁注: 我们曾经使用 readTrusted ,如下所示,但我们不能使用它,因为它正在执行轻量级结帐。并且我们不能使用 gerrit 触发器变量 GERRIT_REFSPEC 进行轻量级结账
def config = readTrusted 'subdir/file'
pipeline {
...
}
答案 0 :(得分:0)
与您的场景类似的示例是
pyspark.sql.utils.IllegalArgumentException: 'Unable to locate hive jars to connect to metastore. Please set spark.sql.hive.metastore.jars.'
就你的情况而言
def config
node {
config = [tgt: "/home"]
}
pipeline {
agent any;
environment {
CC = 'clang'
tgt = "${config.tgt}"
}
stages {
stage('debug') {
steps {
echo CC
echo tgt
}
}
}
}