Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one run allure plugin in jenkins pipeline?

Tags:

jenkins

allure

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?

like image 739
Etki Avatar asked Nov 02 '16 12:11

Etki


People also ask

How do I run a script in Jenkins pipeline?

Click New Item on your Jenkins home page, enter a name for your (pipeline) job, select Pipeline, and click OK. In the Script text area of the configuration screen, enter your pipeline syntax.


3 Answers

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']]
            ])
    }
    }
}
like image 177
RocketRaccoon Avatar answered Oct 07 '22 02:10

RocketRaccoon


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

like image 38
Prabhu Thangaraj Avatar answered Oct 07 '22 02:10

Prabhu Thangaraj


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"
                ]
        )
    }
like image 4
ludenus Avatar answered Oct 07 '22 02:10

ludenus