8

I'm building pipeline/jenkins-based CI for several projects and want to store allure results just as it would be done in regular build with fast access icon. Is it possible from pipeline?

Etki
  • 2,042
  • 2
  • 17
  • 40

3 Answers3

14

We were failed to use Allure Jenkins Plugin in pipeline. It seems that it supports job-dsl-plugin only. So... just add stage where you generate report using Allure CLI and publish report as regular HTML report. Icon for it will be available on job and build screen.

UPDATE

Allure v2 has supported pipeline - see documentation.

stage('reports') {
    steps {
    script {
            allure([
                    includeProperties: false,
                    jdk: '',
                    properties: [],
                    reportBuildPolicy: 'ALWAYS',
                    results: [[path: 'target/allure-results']]
            ])
    }
    }
}
RocketRaccoon
  • 2,559
  • 1
  • 21
  • 30
  • 1
    Did same thing, yep. [It is planned to add pipeline support in v2.0](https://github.com/jenkinsci/allure-plugin/pull/62), btw (NB: plugin name will be changed) – Etki Nov 18 '16 at 11:58
  • @Etki thanks, good news. It would be very useful in case of pipeline and parallel jobs running in docker. – RocketRaccoon Dec 01 '16 at 17:49
  • Yes, they do have pipeline support in allure 2.x, called from pipeline like allure([ jdk: '', properties: [], results: [[path: '/allure-results']] ]) . Note that you should prepare them through gradle/maven tasks during build. – Andrey Regentov Jan 24 '18 at 12:39
5

install the allure plugin for your jenkins. Go to your pipleline build configuration. click on pipeline syntax, select allure reports, fill-in the required fields, click generate syntax, it will give you the required code to be added to your existing groovy scripts

4

I am now using Allure report with Jenkins pipeline You have to perform some additional configuration steps:

_1. Jenkins master must start with the following options as described in http://wiki.qatools.ru/display/AL/Allure+Jenkins+Plugin (sample docker-compose.yaml)

    version: '2'
    services:
      jenkins.master:
      image: jenkins

      # ...

      environment:
        JAVA_OPTS: "-Dhudson.model.DirectoryBrowserSupport.CSP=\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';\" -Djenkins.model.DirectoryBrowserSupport.CSP=\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';\""

_2. HTML Publisher plugin installed from jenkins plugin center

_3. Allure report is generated by maven, sample pom.xml is here https://github.com/ludenus/mobile_test_poc/blob/master/pom.xml

$ mvn -Dmaven.test.failure.ignore=true site

_4. Allure report is published by HTML publisher

    stage('Publish') {
        echo 'Publish Allure report'
        publishHTML(
                target: [
                        allowMissing         : false,
                        alwaysLinkToLastBuild: false,
                        keepAll              : true,
                        reportDir            : 'target/site/allure-maven-plugin',
                        reportFiles          : 'index.html',
                        reportName           : "Allure Report"
                ]
        )
    }
ludenus
  • 1,161
  • 17
  • 30