当我在Jenkinsfile中加载另一个Groovy文件时,它会显示以下错误。
"需要上下文类hudson.FilePath不存在 也许您忘记将代码用提供此类的步骤括起来,例如:node"
我创建了一个包含函数的Groovy文件,并希望在我的Declarative Jenkinsfile中调用它。但是它显示出错。
My Jenkinsfile--->
def myfun = load 'testfun.groovy'
pipeline{
agent any
environment{
REPO_PATH='/home/manish/Desktop'
APP_NAME='test'
}
stages{
stage('calling function'){
steps{
script{
myfun('${REPO_PATH}','${APP_NAME}')
}
}
}
}
}
结果--
org.jenkinsci.plugins.workflow.steps.MissingContextVariableException:需要上下文类hudson.FilePath,但缺少 也许您忘记用提供此内容的步骤将代码包围起来,例如:node
建议我该怎么做。
pipeline
不在顶层。 - gastrodonpipeline
应该在声明式语法中位于顶部。 - rolandsaven