我们没有在 UI 上使用任何后期构建步骤,而是使用 jenkins 管道 groovy 脚本,如下所示:
def allureReportsGenerationTask() {
try {
allure([includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'target/allure-results']]])
} catch(Exception error) {
println("Caught Exception: ${error}")
}
}
项目结构只是这样
ProjectRepo
- src
- target
-alure-results
- pom.xml
- testng.xml
在这种情况下,我们正在生成 allure-results,但它没有在 Jenkins 管道 allure 插件中被选中。 ON UI 下面的命令一直在运行
/opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
您可以看到 Jenkins 在上述 Jenkins 管道命令中无法找到用于生成参数的 allure-results
我们在 pom.xml maven-surefire-plugin 中添加了以下参数
<systemPropertyVariables>
<allure.results.directory>../target/allure-results</allure.results.directory>
</systemPropertyVariables>
现在项目结构变成了
-ProjectRepo
- 源代码
- pom.xml
- testng.xml
现在通过管道脚本运行相同的,我们能够运行以下命令
/opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate /opt/jenkins/workspace/ProjectRepoPipeline/target/allure-results -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
ProjectRepoPipeline - 这是运行 CI/CD 的 Jenkins 管道名称