作业 dsl 中未发生变量替换
Variable substitution not happening in job dsl
只要我的 SVN 存储库中有新的分支条目,就会尝试创建新的作业,下面是脚本。
svnCommand = "svn list --xml http://myrepo/svn/repo_name/branches"
def proc = svnCommand.execute()
proc.waitFor()
def xmlOutput = proc.in.text
def lists = new XmlSlurper().parseText(xmlOutput)
def listOfBranches = lists.list.entry.name
listOfBranches.each(){
def branchName = it.text()
println "found branch: '${branchName}'"
}
mavenJob('${branchName}'){
mavenInstallation('M3.3.9')
logRotator(365, 25, -1, -1)
scm {
svn {
location('http://myrepo/svn/repo_name/branches/${branchName}') {
credentials('4t4d8ef-p67a-5298-a011-580ghe898a65')
}
}
}
}
脚本能够遍历分支并打印分支名称,
找到分支:'feature_01'
但我遇到了问题,在创建作业名称和 svn 分支名称时进行了变量替换。
hudson.model.Failure: ‘$’ is an unsafe character
詹金斯 - V.2.32
作业 DSL - V.1.57
任何建议please.Thanks。
@Rao 是对的:首先 - 你必须改变:
mavenJob('${branchName}')
至:
mavenJob(branchName)
和:
location('http://myrepo/svn/repo_name/branches/${branchName}')
至:
location("http://myrepo/svn/repo_name/branches/${branchName}")
此外 def branchName = it.text()
内部迭代将变量范围限制为仅此迭代。尝试:
listOfBranches.each() {
branchName = it.text()
println "found branch: '${branchName}'"
}
只要我的 SVN 存储库中有新的分支条目,就会尝试创建新的作业,下面是脚本。
svnCommand = "svn list --xml http://myrepo/svn/repo_name/branches"
def proc = svnCommand.execute()
proc.waitFor()
def xmlOutput = proc.in.text
def lists = new XmlSlurper().parseText(xmlOutput)
def listOfBranches = lists.list.entry.name
listOfBranches.each(){
def branchName = it.text()
println "found branch: '${branchName}'"
}
mavenJob('${branchName}'){
mavenInstallation('M3.3.9')
logRotator(365, 25, -1, -1)
scm {
svn {
location('http://myrepo/svn/repo_name/branches/${branchName}') {
credentials('4t4d8ef-p67a-5298-a011-580ghe898a65')
}
}
}
}
脚本能够遍历分支并打印分支名称,
找到分支:'feature_01'
但我遇到了问题,在创建作业名称和 svn 分支名称时进行了变量替换。
hudson.model.Failure: ‘$’ is an unsafe character
詹金斯 - V.2.32
作业 DSL - V.1.57
任何建议please.Thanks。
@Rao 是对的:首先 - 你必须改变:
mavenJob('${branchName}')
至:
mavenJob(branchName)
和:
location('http://myrepo/svn/repo_name/branches/${branchName}')
至:
location("http://myrepo/svn/repo_name/branches/${branchName}")
此外 def branchName = it.text()
内部迭代将变量范围限制为仅此迭代。尝试:
listOfBranches.each() {
branchName = it.text()
println "found branch: '${branchName}'"
}