Closed KevinLuc95 closed 3 years ago
I've solve problem
@KevinLuc95
I've solve problem
What was your solution?
@lrpaquet-jive I missing tash and unstash allure-result and also run it inside Docker, after realizing I separate step generate report to outside Docker
stage('Build & Run Test') {
agent {
docker {
reuseNode true
image 'mcr.microsoft.com/playwright:bionic'
}
}
stages {
stage('Build') {
steps {
sh 'yarn install'
}
}
stage('Run Test') {
steps {
script {
try {
sh 'yarn test ./src/test/smoke/'
stash name: 'allure-results', includes: 'allure-results/*'
currentBuild.result = 'SUCCESS'
} catch (e) {
stash name: 'allure-results', includes: 'allure-results/*'
currentBuild.result = 'FAILED'
throw e
}
}
}
}
}
}
}
post {
always {
unstash 'allure-results' //extract results
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'allure-results']]
])
}
}
}
Hi @KevinLuc95, Thanks for the quick answer!
On my side, I'm still struggling because we're running on a remote slave and, for implementation reasons, I cannot use the tools { }
block in the pipeline.
@lrpaquet-jive just my own thoughts hope it can help you You can download the Allure command line into a slave before running the test and also using Allure Command-Line to generate the report
stage('Generate Report') {
steps {
sh './node_modules/.bin/allure generate ./allure-results'
}
}
@KevinLuc95 Thanks for the suggestion.
I ended up calling another job which has a vanilla pipeline where I can set tools { }
and run directly on the slave(no docker).
Just to clarify the limitation I was facing. I could not execute outside of the docker agent since the pipeline of the job is regulated by a Shared Library.
Isn't there another way to make it work other than having to specify the docker agent at stage level on each step? I was able to make it work by using agent any at the pipeline level and then for each stage specifying a docker agent but it became kind of annoying because i had to repeat that block on each stage since im using the same image and args for all of my stages, and if i have it at the pipeline level it fails to run the allure step.
Another alternative i was trying out was using allure command line inside my container and then generate my report at the root of my workspace in the /allure-report folder, it looks exactly the same when browsing through my workspace files when comparing to an old version of my pipeline where i still was not using docker, but now it doesn't display the link to show the allure report, even tho i made sure to generate the output in the expected path and to save the artifact inside the build. It is important to note that in this last attempt i tried not using the plugin and instead just generating the output and persisting it through jenkins in the expected paths.
@lrpaquet-jive I missing tash and unstash allure-result and also run it inside Docker, after realizing I separate step generate report to outside Docker
stage('Build & Run Test') { agent { docker { reuseNode true image 'mcr.microsoft.com/playwright:bionic' } } stages { stage('Build') { steps { sh 'yarn install' } } stage('Run Test') { steps { script { try { sh 'yarn test ./src/test/smoke/' stash name: 'allure-results', includes: 'allure-results/*' currentBuild.result = 'SUCCESS' } catch (e) { stash name: 'allure-results', includes: 'allure-results/*' currentBuild.result = 'FAILED' throw e } } } } } } } post { always { unstash 'allure-results' //extract results script { allure([ includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'allure-results']] ]) } } }
I tried exactly your approach with stash/unstash, but I'm still getting the same exception:
OCI runtime exec failed: exec failed: unable to start container process: exec: "/home/ec2-user/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure": stat /home/ec2-user/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure: no such file or directory: unknown
[Pipeline] }
[Pipeline] // script
Error when executing always post condition:
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 77d4fe76-70e6-4881-a2fe-e62ee440c67d
ru.yandex.qatools.allure.jenkins.exception.AllurePluginException: Can not generate Allure Report, exit code: 126
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.generateReport(AllureReportPublisher.java:359)
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.perform(AllureReportPublisher.java:269)
at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:101)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:71)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Anyone any ideas what might be wrong? All the files are generated (I even tried downloading them and I'm able to generate the report from them locally - it works).
Reproduction steps
currently, i'm running the e2e automation test in Jenkins pipeline and I cannot generate report inside jenkins pipeline. Please help