jenkinsci / allure-plugin

Allure Jenkins Plugin
https://plugins.jenkins.io/allure-jenkins-plugin/
Other
84 stars 65 forks source link

allure bin should not execute in docker container when pipeline use docker to setup agent #163

Open wuhuizuo opened 6 years ago

wuhuizuo commented 6 years ago

Issue

Context

Problem description

Allure Report should generate in Docker host instead of container inside:

Logs & Traces

[Pipeline] allure
Unpacking http://200.200.0.36/opensource/jenkinstool/raw/test/tools/allure-2.2.1.zip to /home/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure_cli on DockerHost-100-100-165-1
[PipeTestPiece] $ docker exec c314f07abd79b61de88e1db991ea32063a284f043ad02a5f5a44a720d549ee01 env "ALLURE_OPTS=-Dallure.tests.management.pattern=http://200.200.0.37/test_points/%s/normal_usecases -Dallure.issues.tracker.pattern=http://200.200.0.23/%s " API_VERSION=hci5.3 BUILD_DISPLAY_NAME=#21914 BUILD_ID=21914 BUILD_NUMBER=21914 BUILD_TAG=jenkins-PipeTestPiece-21914 BUILD_URL=http://200.200.166.1:8080/job/PipeTestPiece/21914/ CLASSPATH= GIT_BRANCH=HCI5.3 GIT_URL=http://200.200.0.36/vmp/vmp-testing.git HUDSON_HOME=/var/jenkins_home HUDSON_SERVER_COOKIE=263b78fc48c45133 HUDSON_URL=http://200.200.166.1:8080/ JENKINS_HOME=/var/jenkins_home JENKINS_SERVER_COOKIE=263b78fc48c45133 JENKINS_URL=http://200.200.166.1:8080/ JOB_BASE_NAME=PipeTestPiece JOB_DISPLAY_URL=http://200.200.166.1:8080/job/PipeTestPiece/display/redirect JOB_NAME=PipeTestPiece JOB_URL=http://200.200.166.1:8080/job/PipeTestPiece/ REQUEST_ASKS=type=storage_iscsi;type=storage_iscsi;*1:type=cluster,cfg.member.size>=2,cfg.vs_enable=1,label.sn=pro,label.for=bdd,label.lang=zh,label.version=hci5.3;&1.cfg.member "RSPEC_PARAM=--tag smoke --tag ~adesk_only spec/func/asv_only/vm/shutdown_time_spec.rb spec/func/asv_only/backup/vm/migrate_spec.rb spec/func/asv_only/backup/vm/template_spec.rb spec/func/asv_only/backup/vm/disk_spec.rb spec/func/asv_only/backup/vm/import_spec.rb" RUN_CHANGES_DISPLAY_URL=http://200.200.166.1:8080/job/PipeTestPiece/21914/display/redirect?page=changes RUN_DISPLAY_URL=http://200.200.166.1:8080/job/PipeTestPiece/21914/display/redirect SHARE_MOUNT=/var/reportCacheHub SpecStatusUrl= TES_HTTP=http://200.200.166.1:9292 /home/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure_cli/allure-2.2.1/bin/allure generate -o /home/jenkins/workspace/PipeTestPiece/allure-report
env: ‘/home/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure_cli/allure-2.2.1/bin/allure’: No such file or directory
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 c314f07abd79b61de88e1db991ea32063a284f043ad02a5f5a44a720d549ee01
$ docker rm -f c314f07abd79b61de88e1db991ea32063a284f043ad02a5f5a44a720d549ee01
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

Pipeline Jenkinsfile

def user = "${env.JOB_NAME}#${env.BUILD_ID}"
manager.addInfoBadge('spec:' + params.RSPEC_PARAM)
manager.addShortText('branch:' + params.GIT_BRANCH)
manager.addShortText('api:' + params.API_VERSION)

if (params.SpecStatusUrl) {
    manager.addShortText('only_failures', 'red', "white", "1px", "red")
}

def poolRequestFile = 'env_profile'
def scm = [
                $class           : 'GitSCM',
                branches         : [[name: GIT_BRANCH]],
                extensions       : [[$class: 'CleanBeforeCheckout']],
                userRemoteConfigs: [[url: GIT_URL]]
        ]
def rspecCmd = 'bundle exec rspec --dry-run'
rspecCmd += " ${RSPEC_PARAM}"

pipeline {
    agent {
        docker {
            label 'Docker&&TestNet'
            image 'wuhuizuo/ruby-tes-vtp:latest'
        }
    }
    stages {
        stage('UpdateCode') {
            steps { checkout(scm: scm) }
        }
        stage('Request Env') {
            steps {
                writeFile(file: poolRequestFile, text: params.REQUEST_ASKS)
                sh "tes-client \${TES_HTTP} ${user} request_pool ${poolRequestFile} test_device.yml"
                archiveArtifacts 'test_device.yml'
            }
        }
        stage('Test Setup') {
            steps {
                unarchive(mapping: ['test_device.yml': 'config/test_device.yml'])
                sh 'rm -rf rspec_reports allure-report'
                sh 'bundle'
                sh "bundle exec rake setTestDevice[:version,=,${API_VERSION}]\n"
                sh "bundle exec ruby tool/clean.rb all"
            }
        }
        stage('Test') {
            steps {
                script {
                    if (SpecStatusUrl) {
                        sh "wget -q \"${SpecStatusUrl}\" -O spec/.status"
                        rspecCmd += " --only-failures"
                    }
                }
                sh rspecCmd
            }
            post {
                always {
                    // archive test result
                    archiveArtifacts 'spec/.status'
                    sh "cd ${WORKSPACE}/rspec_reports; tar -zcf ../report.tar.gz ."
                    archiveArtifacts 'report.tar.gz'

                    // clean test device
                    sh 'vtp-tool-qa purge_env_storage test_device.yml'
                }
            }
        }
    }
    post {
        always {
            sh "tes-client \${TES_HTTP} ${user} release_pool"
            // generate report
            allure(
                  results: [[path: 'rspec_reports']],
                  reportBuildPolicy: 'ALWAYS',
                  includeProperties: true,
                  properties: [
                          [key: 'allure.tests.management.pattern', value: 'http://200.200.0.37/test_points/%s/normal_usecases'],
                          [key: 'allure.issues.tracker.pattern', value: 'http://200.200.0.23/%s']
                  ]
            )
        }
    }
}
wuhuizuo commented 6 years ago

@eroshenkoam PLS check this issue

eroshenkoam commented 6 years ago

@wuhuizuo, ok, I'll check it in the evening

yorammi commented 6 years ago

I have a similar issue. I'm using Dockerfile as the agent, I see the tests that runs OK in the console output and I can find the tests results in the allure-results folder as expected, but the allure command output in the console output is just:

[Pipeline] stage [Pipeline] { (Declarative: Post Actions) [Pipeline] allure [Pipeline] }

And not allure report created. When I run it outside of a Docker container as an agent it works OK.

yorammi commented 6 years ago

After upgrading the plugin to the latest one (2.2.5) and mounting the container to the server's allure-tool and JDK paths, it started running, but I'm getting the following error:

Error: Could not find or load main class io.qameta.allure.CommandLine

 The full output:

00:13:35.681 [taurus-script-runner] $ docker exec f6bf92a61bf4bf643a60f2afb1be06109f928a06b969202d8f80cfee90757153 env ALLURE_HOME=/var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/2.4.1 'ALLURE_OPTS="-Dhttpallure.tests.management.pattern=http://tms.company.com/%s" ' API_TESTING_BRANCH=taurus_test_migration_jenkins2 BUILD_DISPLAY_NAME=#54 BUILD_ID=54 BUILD_NUMBER=54 BUILD_TAG=jenkins-taurus-script-runner-54 BUILD_URL=http://xxx.com:8080/job/taurus-script-runner/54/ CLASSPATH= HUDSON_HOME=/var/lib/jenkins HUDSON_SERVER_COOKIE=3c0c5777b68f7d2a HUDSON_URL=http://xxx.com:8080/ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 JENKINS_SERVER_COOKIE=3c0c5777b68f7d2a JENKINS_URL=http://xxx.com:8080/ JOB_BASE_NAME=taurus-script-runner JOB_DISPLAY_URL=http://xxx.com:8080/job/taurus-script-runner/display/redirect JOB_NAME=taurus-script-runner JOB_URL=http://xxx.com:8080/job/taurus-script-runner/ RUN_CHANGES_DISPLAY_URL=http://xxx.com:8080/job/taurus-script-runner/54/display/redirect?page=changes RUN_DISPLAY_URL=http://xxx.com:8080/job/taurus-script-runner/54/display/redirect SDK_BRANCH=master library.jenkins_library.version=master /var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/2.4.1/bin/allure generate -o /var/lib/jenkins/workspace/taurus-script-runner/allure-report 00:13:35.834 Error: Could not find or load main class io.qameta.allure.CommandLine

yorammi commented 6 years ago

@eroshenkoam - any estimation when this will be resolved/handled? Thanks!

aspekt112 commented 6 years ago

Is there any workflow to resolve this issue?

wendywww commented 6 years ago

Is there any update on this issue? @eroshenkoam I think I also updated samilar issue https://github.com/jenkinsci/allure-plugin/issues/207

JohnnyChiang commented 3 years ago

Well, any update in 2020?

EitanBe commented 3 years ago

Any update has the same issue 2021?

KevinLuc95 commented 3 years ago

same question, any update in 2021????

Tyson1986 commented 2 years ago

Any update?

nindza commented 2 years ago

Any update 2022?

snowsky commented 6 months ago

Any update in 2024? The job was successful with docker agent but failed recently.