Home > Mobile >  Allure report is showing empty contents after Jenkins job execution
Allure report is showing empty contents after Jenkins job execution

Time:11-24

I have a Jenkins job "FEXT_21.4_AUTOMATION", that is to execute some selenium test cases in docker, and the one of the post job work is to generate the allure report. But somehow, the report is always of 0 results !

Following picture is my job configuration.

As you may find in which, I have this command to have the test cases executed in docker.

docker-compose -f docker-compose.yml run --rm -v ${ROOT}/allure-reports:/allure-reports fext_extender behave ...

Since the output files of ownership "root", I have the 2nd command to workaround to change the whole /allure-reports ownership.

docker run --rm -i --entrypoint /bin/sh -e HOST_UID=`id -u` -v ${ROOT}/allure-reports:/allure-reports alpine:latest -c 'chown -R ${HOST_UID}:${HOST_UID} /allure-reports/' 

from the console of one job execution, I can see everything was carried over smoothly, and allure report is generated.

...
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
8 steps passed, 0 failed, 0 skipped, 0 undefined
Took 1m2.060s
  id -u
  docker run --rm -i --entrypoint /bin/sh -e HOST_UID=111 -v /var/lib/jenkins/workspace/FEXT_21.4_AUTOMATION/allure-reports:/allure-reports alpine:latest -c chown -R ${HOST_UID}:${HOST_UID} /allure-reports/
  set -e
[FEXT_21.4_AUTOMATION] $ /usr/share/allure/bin/allure generate /var/lib/jenkins/workspace/FEXT_21.4_AUTOMATION/allure-reports -c -o /var/lib/jenkins/workspace/FEXT_21.4_AUTOMATION/allure-report
Report successfully generated to /var/lib/jenkins/workspace/FEXT_21.4_AUTOMATION/allure-report
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Finished: SUCCESS

But somehow, if I click the allure link, I can only see a 0-testcase results.

From the platform where the Jenkins tasks are being hold, I can see these 2 extra files created under "allure-reports" when allure generate command is called.

jenkins@Jenkins-CJI:~/workspace/FEXT_21.4_AUTOMATION/allure-reports$ pwd
/var/lib/jenkins/workspace/FEXT_21.4_AUTOMATION/allure-reports
jenkins@Jenkins-CJI:~/workspace/FEXT_21.4_AUTOMATION/allure-reports$ whoami
jenkins
jenkins@Jenkins-CJI:~/workspace/FEXT_21.4_AUTOMATION/allure-reports$ ls -ltr | tail -5
-rw-r--r-- 1 jenkins messagebus  78515 Nov 18 15:29 Screenshot_2021-11-18T18:29:25.491659_1637278165.4916792.png
-rw-r--r-- 1 jenkins messagebus 134025 Nov 18 15:29 Screenshot_2021-11-18T18:29:26.011988_1637278166.0120175.png
-rw-r--r-- 1 jenkins messagebus 134025 Nov 18 15:29 Screenshot_2021-11-18T18:29:26.384782_1637278166.3848066.png
-rw-r--r-- 1 jenkins messagebus     78 Nov 18 15:29 testrun.json
-rw-r--r-- 1 jenkins messagebus    295 Nov 18 15:29 executor.json

And here is the allure-report looks like:

jenkins@Jenkins-CJI:~/workspace/FEXT_21.4_AUTOMATION$ tree -L 2 allure-report
allure-report
├── app.js
├── data
│   ├── attachments
│   ├── behaviors.csv
│   ├── behaviors.json
│   ├── categories.csv
│   ├── categories.json
│   ├── packages.json
│   ├── suites.csv
│   ├── suites.json
│   ├── test-cases
│   └── timeline.json
├── export
│   ├── influxDbData.txt
│   ├── mail.html
│   └── prometheusData.txt
├── favicon.ico
├── history
│   ├── categories-trend.json
│   ├── duration-trend.json
│   ├── history.json
│   ├── history-trend.json
│   └── retry-trend.json
├── index.html
├── plugins
│   ├── behaviors
│   ├── junit
│   ├── packages
│   ├── screen-diff
│   ├── trx
│   ├── xctest
│   └── xunit-xml
├── styles.css
└── widgets
    ├── behaviors.json
    ├── categories.json
    ├── categories-trend.json
    ├── duration.json
    ├── duration-trend.json
    ├── environment.json
    ├── executors.json
    ├── history-trend.json
    ├── launch.json
    ├── retry-trend.json
    ├── severity.json
    ├── status-chart.json
    ├── suites.json
    └── summary.json

Does anyone know why allure report is empty ?

Thanks for the help.

Jack

CodePudding user response:

Instead of ${ROOT} use ${WORKSPACE}. WORKSPACE is a Jenkins variable that contains the WORKSPACE PATH

-v ${WORKSPACE}/allure-reports:/allure-reports

Also, check after running the job if there are some alure results files in the /allure-results directory inside the Jenkins workspace here:

enter image description here

If you don't see any results files in the workspace, it's because you are not mounting the right internal directory in the container, in this case /allure-reports (inside the container)

CodePudding user response:

These are my final commands in junkins job to create success allure reports.

docker-compose -f docker-compose.yml run --rm -v ${WORKSPACE}/allure-reports:/allure-reports fext_extender behave -verbose -f allure_behave.formatter:AllureFormatter -f pretty -o /allure-reports <feature_files>

docker run --rm -i --entrypoint /bin/sh -e HOST_UID=`id -u` -v ${WORKSPACE}/allure-reports:/allure-reports alpine:latest -c 'chown -R ${HOST_UID}:${HOST_UID} /allure-reports/' 

Comments:

  • As Frank mentioned here, https://gitter.im/allure-docker-service/community?at=5f2987858d82e662520511be, need to mount a volume, something as if "${WORKSPACE}/allure-reports:/allure-reports".
  • the ownership of the docker execution output files is "root", need to find a way to have the ${WORKSPACE}/allure-reports ownership changed to be "Jenkins". Otherwise, the follow-up allure generate run will be failed, as no permission inside /allure-reports.
  • In my first command, I was using "... -o ./allure-reports", which is not the same location as "... -o /allure-reports". And because of that, the list of "...-result.json" files were not generated after 1st command execution!

After I have these 3 area corrected, I have my Jenkins results in the end.

  • Related