我们有一些类似的应用程序,这些应用程序由 scripted pipeline部署,基本上是所有应用程序上的c& p。我想将整个管道转移到詹金斯(Jenkins(的詹金斯(Jenkins(文档中。
。所以让我们假设我在 var/standardSpringPipeline.groovy
中有以下"管道":
#!groovy
def call() {
node {
echo "${env.BRANCH_NAME}"
}
}
然后 - 詹金斯文件:
@Library('my-jenkins-lib@master') _
standardSpringPipeline
echo "Bye!"
不幸的是,这是我不了解的原因。詹金斯输出相似:
> git fetch --no-tags --progress ssh://git@***.com:7999/log/my-jenkins-lib.git +refs/heads/*:refs/remotes/origin/*
Checking out Revision 28900d4ed5bcece9451655f6f1b9a41a76256629 (master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 28900d4ed5bcece9451655f6f1b9a41a76256629
Commit message: "NOJIRA: ...."
> git rev-list --no-walk 28900d4ed5bcece9451655f6f1b9a41a76256629 # timeout=10
[Pipeline] echo
Bye!
[Pipeline] End of Pipeline
任何线索为什么它不起作用(请参见上面的输出(,正确的方法是什么?
对于无ARG方法,您不能使用可选的括号。摘自Groovy文档(重点是我的(:
方法调用如果至少有一个参数并且没有歧义,则可以省略括号:
println 'Hello World' def maximum = Math.max 5, 10
括号是没有参数的方法调用或 模棱两可的方法:
println() println(Math.max(5, 10))
standardSpringPipeline
的行为像是一种方法,因为它的编译方式。如果添加echo "$standardSpringPipeline"
,则可以更清楚地知道它是可以调用的汇编类。
要解决您的问题,只需将括号添加到呼叫中:
standardSpringPipeline()