hudson.FilePath is missing error 当通过管道脚本生成诱惑报告时
·
问题:hudson.FilePath is missing error 当通过管道脚本生成诱惑报告时
我在管道中添加了新阶段:
stage('reports') {
steps {
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'target/allure-results']]
])
}
}
}
但是作业失败并出现错误:
hudson.remoting.ProxyException: org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing
at org.jenkinsci.plugins.workflow.steps.StepDescriptor.checkContextAvailability(StepDescriptor.java:260)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:262)
Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing
测试是在 Python 和生成的 xml 报告上编写的,但不是诱惑报告。
你能帮我解决这个错误吗?
解答
如我所见,您使用声明性管道语法。在这种情况下,您需要定义agent
部分。来自官方文档:
在 Pipeline 的顶层定义
agent none
可确保不会不必要地分配 Executor。使用agent none
还会强制每个stage
部分包含其自己的agent
部分。
所以,我认为你在管道的顶层使用agent none
,这就是为什么你需要在你的阶段中添加agent
部分。像这样的东西:
pipeline {
agent none
stages {
stage('reports') {
agent { docker 'openjdk:8-jre' }
steps {
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'target/allure-results']]
])
}
}
}
}
}
对于脚本化管道您需要使用此语法(有关详细信息,请参阅 allure文档):
node {
// script body
allure([
includeProperties: false,
jdk: '',
properties: [[key: 'allure.issues.tracker.pattern', value: 'http://tracker.company.com/%s']],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'target/allure-results'], [path: 'other_target/allure-results']]
])
}
更多推荐
所有评论(0)