jenkinsci / allure-plugin

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

Can't find a way to pass JVM parameters to `allure` from Jenkins pipeline #360

Open eplodn opened 5 months ago

eplodn commented 5 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.440.1 OS: Linux - 5.3.0-1030-aws Java: 17.0.10 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- allure-jenkins-plugin:2.31.1 amazon-ecr:1.114.vfd22430621f5 analysis-model-api:12.1.0 ansicolor:1.0.4 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 artifact-manager-s3:845.848.ve968b_8576c1c asm-api:9.6-3.v2e1fa_b_338cd7 authentication-tokens:1.53.v1c90fd9191a_b_ aws-bucket-credentials:1.0.0 aws-credentials:218.v1b_e9466ec5da_ aws-global-configuration:130.v35b_7b_96f53c3 aws-java-sdk:1.12.671-439.veec746c91fcb_ aws-java-sdk-cloudformation:1.12.671-439.veec746c91fcb_ aws-java-sdk-codebuild:1.12.671-439.veec746c91fcb_ aws-java-sdk-ec2:1.12.671-439.veec746c91fcb_ aws-java-sdk-ecr:1.12.671-439.veec746c91fcb_ aws-java-sdk-ecs:1.12.671-439.veec746c91fcb_ aws-java-sdk-efs:1.12.671-439.veec746c91fcb_ aws-java-sdk-elasticbeanstalk:1.12.671-439.veec746c91fcb_ aws-java-sdk-iam:1.12.671-439.veec746c91fcb_ aws-java-sdk-kinesis:1.12.671-439.veec746c91fcb_ aws-java-sdk-logs:1.12.671-439.veec746c91fcb_ aws-java-sdk-minimal:1.12.671-439.veec746c91fcb_ aws-java-sdk-secretsmanager:1.12.671-439.veec746c91fcb_ aws-java-sdk-sns:1.12.671-439.veec746c91fcb_ aws-java-sdk-sqs:1.12.671-439.veec746c91fcb_ aws-java-sdk-ssm:1.12.671-439.veec746c91fcb_ basic-branch-build-strategies:81.v05e333931c7d blueocean:1.27.11 blueocean-bitbucket-pipeline:1.27.11 blueocean-commons:1.27.11 blueocean-config:1.27.11 blueocean-core-js:1.27.11 blueocean-dashboard:1.27.11 blueocean-display-url:2.4.2 blueocean-events:1.27.11 blueocean-git-pipeline:1.27.11 blueocean-github-pipeline:1.27.11 blueocean-i18n:1.27.11 blueocean-jwt:1.27.11 blueocean-personalization:1.27.11 blueocean-pipeline-api-impl:1.27.11 blueocean-pipeline-editor:1.27.11 blueocean-pipeline-scm-api:1.27.11 blueocean-rest:1.27.11 blueocean-rest-impl:1.27.11 blueocean-web:1.27.11 bootstrap5-api:5.3.3-1 bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9 branch-api:2.1152.v6f101e97dd77 build-token-root:151.va_e52fe3215fc buildtriggerbadge:251.vdf6ef853f3f5 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 cloudbees-bitbucket-branch-source:880.vcf4056c5a_71f cloudbees-folder:6.901.vb_4c7a_da_75da_3 cobertura:1.17 code-coverage-api:4.99.0 command-launcher:107.v773860566e2e commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-95.v22a_d30ee5d36 copyartifact:722.v0662a_9b_e22a_c coverage:1.13.0 credentials:1337.v60b_d7b_c7b_c9f credentials-binding:657.v2b_19db_7d6e6d data-tables-api:2.0.2-1 display-url-api:2.200.vb_9327d658781 docker-commons:439.va_3cb_0a_6a_fb_29 durable-task:550.v0930093c4b_a_6 ec2:1648.vf3d852e00486 ec2-fleet:3.2.0 echarts-api:5.5.0-1 extended-read-permission:53.v6499940139e5 external-monitor-job:215.v2e88e894db_f8 favorite:2.208.v91d65b_7792a_c font-awesome-api:6.5.1-3 forensics-api:2.4.0 generic-webhook-trigger:2.0.2 git:5.2.1 git-client:4.7.0 git-parameter:0.9.19 github:1.38.0 github-api:1.318-461.v7a_c09c9fa_d63 github-branch-source:1781.va_153cda_09d1b_ github-oauth:597.ve0c3480fcb_d0 github-scm-trait-notification-context:40.vfa_7f31a_b_d7f8 groovy:457.v99900cb_85593 gson-api:2.10.1-15.v0d99f670e0a_7 handy-uri-templates-2-api:2.1.8-30.v7e777411b_148 htmlpublisher:1.33 http_request:1.18 instance-identity:185.v303dc7c645f9 ionicons-api:56.v1b_1c8c49374e jackson2-api:2.16.2-378.v7e79818f53ce jakarta-activation-api:2.1.3-1 jakarta-mail-api:2.1.3-1 javadoc:243.vb_b_503b_b_45537 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:73.vddf737284550 jenkins-design-language:1.27.11 jersey2-api:2.41-133.va_03323b_a_1396 jjwt-api:0.11.5-77.v646c772fddb_0 jobConfigHistory:1229.v3039470161a_d joda-time-api:2.12.7-29.v5a_b_e3a_82269a_ jquery:1.12.4-1 jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240303-41.v94e11e6de726 json-path-api:2.9.0-52.v57de85cc4722 junit:1259.v65ffcef24a_88 ldap:711.vb_d1a_491714dc mailer:472.vf7c289a_4b_420 mapdb-api:1.0.9-28.vf251ce40855d material-theme:0.5.2-rc100.6121925fe229 matrix-auth:3.2.2 matrix-project:822.824.v14451b_c0fd42 maven-plugin:3.23 metrics:4.2.21-449.v6960d7c54c69 mina-sshd-api-common:2.12.0-90.v9f7fb_9fa_3d3b_ mina-sshd-api-core:2.12.0-90.v9f7fb_9fa_3d3b_ node-iterator-api:55.v3b_77d4032326 okhttp-api:4.11.0-172.vda_da_1feeb_c6e pam-auth:1.10 parameterized-scheduler:262.v00f3d90585cc pipeline-aws:1.43 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-github:2.8-159.09e4403bc62f pipeline-github-lib:42.v0739460cda_c4 pipeline-graph-analysis:216.vfd8b_ece330ca_ pipeline-graph-view:237.v8959b_75f3c47 pipeline-groovy-lib:704.vc58b_8890a_384 pipeline-input-step:491.vb_07d21da_1a_fb_ pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2184.v0b_358b_953e69 pipeline-model-definition:2.2184.v0b_358b_953e69 pipeline-model-extensions:2.2184.v0b_358b_953e69 pipeline-rest-api:2.34 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2184.v0b_358b_953e69 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.2 plain-credentials:179.vc5cb_98f6db_38 plugin-util-api:4.1.0 prism-api:1.29.0-13 pubsub-light:1.18 read-only-configurations:1.10 rebuild:330.v645b_7df10e2a_ resource-disposer:0.23 s3:466.vf5b_3db_8e3eb_2 scm-api:689.v237b_6d3a_ef7f scm-filter-branch-pr:148.v0b_5f06e8b_c84 script-security:1326.vdb_c154de8669 simple-theme-plugin:176.v39740c03a_a_f5 slack:684.v833089650554 snakeyaml-api:2.2-111.vc6598e30cc65 sse-gateway:1.26 ssh-agent:346.vda_a_c4f2c8e50 ssh-credentials:322.v124df57ed808 ssh-slaves:2.948.vb_8050d697fec sshd:3.322.v159e91f6a_550 structs:337.v1b_04ea_4df7c8 theme-manager:215.vc1ff18d67920 throttle-concurrents:2.14 timestamper:1.26 token-macro:400.v35420b_922dcb_ trilead-api:2.142.v748523a_76693 uno-choice:2.8.1 variant:60.v7290fc0eb_b_cd warnings-ng:11.2.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1291.v51fd2a_625da_7 workflow-basic-steps:1049.v257a_e6b_30fb_d workflow-cps:3883.vb_3ff2a_e3eea_f workflow-durable-task-step:1331.vc8c2fed35334 workflow-job:1400.v7fd111b_ec82f workflow-multibranch:773.vc4fe1378f1d5 workflow-scm-step:427.v4ca_6512e7df1 workflow-step-api:657.v03b_e8115821b_ workflow-support:865.v43e78cc44e0d ws-cleanup:0.45 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu Linux 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP

Reproduction steps

We want to pass the -Xmx2G parameter to the allure but can't find a way to do so.

Trying with INVALIDNUMBER instead of 2G:

withEnv(['JAVA_OPTS=-XmxINVALIDNUMBER']) {
    allure([
            includeProperties: true,
            jdk: '',
            properties: [],
            reportBuildPolicy: 'ALWAYS',
            results: allure_results,
            report: "${env.WORKSPACE}/allure-report.zip"
    ])
}

Expected Results

I expected this to fail, like with

/tmp/allure-2.28.0/bin$ JAVA_OPTS=-XmxINVALIDNUMBER ./allure
Invalid maximum heap size: -XmxINVALIDNUMBER
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Actual Results

Actually it succeeds. It seems that the environment variable is not passed to the allure command line installation, so I can't pass a valid number to fix my issue.

Anything else?

We have many test stages that produce allure results. We aggregate them in the end.

allure([
        includeProperties: false,
        jdk: '',
        properties: [],
        reportBuildPolicy: 'ALWAYS',
        results: allure_results,
        report: "${env.WORKSPACE}/allure-report.zip"
])

Recently, the number of stages grew, so the pipeline runs in an out-of-heap-space issue.

[Pipeline] allure
[2024-04-15T03:30:05.458Z] [myjob] $ /var/jenkins_home/tools/ru.ya...llation/allure/bin/allure generate 
  /var/jenkins_home/workspace/myjob/aaa_1_2__allure_results

  [300 lines omitted]

  /var/jenkins_home/workspace/myjob/zzz_8_8__allure_results
  -c -o /var/jenkins_home/workspace/myjob/allure-report.zip
[2024-04-15T03:31:59.167Z] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[2024-04-15T03:31:59.168Z]      at java.base/java.lang.Long.valueOf(Long.java:1180)

Allure on Jenkins is installed from Maven (latest version).

Are you interested in contributing a fix?

No response

amilovanovikj commented 5 months ago

@eplodn I encountered the same issue and fixed it by editing the allure shell script on my Jenkins server (which the allure plugin uses) and added the JVM opts under the following variable:

# Add default JVM options here. You can also use JAVA_OPTS and ALLURE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="-Xms4096M -Xmx8192M"

Not sure if this workaround is applicable in your scenario though...

felipecrs commented 1 month ago

@amilovanovikj is this file on your Jenkins master home or on your agents?

amilovanovikj commented 1 month ago

@felipecrs the file is located on the Jenkins master node. The path on the server should be: ${JENKINS_HOME}/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure-<version>/bin/allure

felipecrs commented 1 month ago

That's very helpful, thank you very much!