对promotionConfig反序列化变量

时间:2017-12-11 22:55:43

标签: jenkins-pipeline artifactory

我正在尝试将带有repo名称的变量(repoName)传递给promotionConfig参数 targetRepo sourceRepo ,但我在Jenkins中收到此错误:< / p>

通知建立结果 com.fasterxml.jackson.databind.JsonMappingException:无法从START_OBJECT标记中反序列化java.lang.String的实例  在[资料来源:N / A; line:-1,column:-1](通过引用链:org.jfrog.hudson.pipeline.types.PromotionConfig [&#34; targetRepo&#34;])

我在promotionConfig中使用:

...
'targetRepo'         : '${repoName}-release-local',
...
'sourceRepo'         : '${repoName}-snapshot-local',
...

变量repoName

echo "Repo name is ${repoName}"

输出:回购名称为 test-repo

任何人都知道将变量传递给promotionConfig的正确方法吗?

1 个答案:

答案 0 :(得分:1)

您应该使用双引号在字符串中传递变量。

def var = "${repoName}".toString()
...
'targetRepo'         : "" + var + "-release-local",   
...
'sourceRepo'         : "" + var + "-snapshot-local",
...