The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

JUnit Plugin

junit: Archive JUnit-formatted test results

Jenkins understands the JUnit test report XML format (which is also used by TestNG). When this option is configured, Jenkins can provide useful information about test results, such as historical test result trends, a web UI for viewing test reports, tracking failures, and so on.

To use this feature, first set up your build to run tests, then specify the path to JUnit XML files in the Ant glob syntax, such as **/build/test-reports/*.xml. Be sure not to include any non-report files into this pattern. You can specify multiple patterns of files separated by commas.

  • testResults : String
  • allowEmptyResults : boolean (optional)
    If checked, the default behavior of failing a build on missing test result files or empty test results is changed to not affect the status of the build. Please note that this setting make it harder to spot misconfigured jobs or build failures where the test tool does not exit with an error code when not producing test report files.
  • checksName : String (optional)
    If provided, and publishing checks enabled, the plugin will use this name when publishing results to corresponding SCM hosting platforms. If not, a default including the current stage / branch names will be used.
  • healthScaleFactor : double (optional)
    The amplification factor to apply to test failures when computing the test result contribution to the build health score.
    The default factor is 1.0
    • A factor of 0.0 will disable the test result contribution to build health score.
    • A factor of 0.1 means that 10% of tests failing will score 99% health
    • A factor of 0.5 means that 10% of tests failing will score 95% health
    • A factor of 1.0 means that 10% of tests failing will score 90% health
    • A factor of 2.0 means that 10% of tests failing will score 80% health
    • A factor of 2.5 means that 10% of tests failing will score 75% health
    • A factor of 5.0 means that 10% of tests failing will score 50% health
    • A factor of 10.0 means that 10% of tests failing will score 0% health
    The factor is persisted with the build results, so changes will only be reflected in new builds.
  • keepLongStdio : boolean (optional)
    If checked, any standard output or error from a test suite will be retained in the test results after the build completes. (This refers only to additional messages printed to console, not to a failure stack trace.) Such output is always kept if the test failed, but by default lengthy output from passing tests is truncated to save space. Check this option if you need to see every log message from even passing tests, but beware that Jenkins's memory consumption can substantially increase as a result, even if you never look at the test results!
  • keepProperties : boolean (optional)
  • skipMarkingBuildUnstable : boolean (optional)
    If this option is unchecked, then the plugin will mark the build as unstable when it finds at least 1 test failure. If this option is checked, then the build will still be successful even if there are test failures reported. In any case, the corresponding pipeline node (and stage) will be marked as unstable in case of test failure.
  • skipOldReports : boolean (optional)
  • skipPublishingChecks : boolean (optional)
    If this option is unchecked, then the plugin automatically publishes the test results to corresponding SCM hosting platforms. For example, if you are using this feature for a GitHub organization project, the warnings will be published to GitHub through the Checks API. If this operation slows down your build, or you don't want to publish the warnings to SCM platforms, you can use this option to deactivate this feature.
  • stdioRetention : String (optional)
  • testDataPublishers (optional)
      Array / List of Nested Choice of Objects
    • attachments
      • $class: 'AutomateTestDataPublisher'
        • $class: 'ClaimTestDataPublisher'
          • $class: 'JUnitFlakyTestDataPublisher'
            • jiraTestResultReporter
              • configs
                  Array / List of Nested Choice of Objects
                • jiraSelectableArrayField
                  • fieldKey : String
                  • values
                      Array / List of Nested Object
                    • value : String
                • jiraSelectableField
                  • fieldKey : String
                  • value : String
                • jiraStringArrayField
                  • fieldKey : String
                  • values
                      Array / List of Nested Object
                    • value : String
                • jiraStringField
                  • fieldKey : String
                  • value : String

                    Insert a string value.

                    You can include Jenkins Environment variables (see link), or the following variables defined by this plugin:

                    Variable usage: ${VAR_NAME}

                    CRFL - new line

                    DEFAULT_SUMMARY - configured in the global configuration page

                    DEFAULT_DESCRIPTION - configured in the global configuration page

                    TEST_RESULT

                    TEST_NAME

                    TEST_FULL_NAME

                    TEST_STACK_TRACE

                    TEST_ERROR_DETAILS

                    TEST_DURATION

                    TEST_PACKAGE_NAME

                    TEST_PACKAGE_CLASS_METHOD_NAME

                    TEST_STDERR

                    TEST_STDOUT

                    TEST_OVERVIEW

                    TEST_AGE

                    TEST_PASS_COUNT

                    TEST_SKIPPED_COUNT

                    TEST_FAIL_SINCE

                    TEST_IS_REGRESSION - expands to true/false

                    BUILD_RESULT

                    WARNING: Your input will not be validated against the server's metadata. Check Jira to make sure you insert a valid value for this field and use the Validate Fields button bellow, otherwise the plugin will fail to create your issue.

                • jiraUserField
                  • fieldKey : String
                  • value : String

                    Insert the username.

                    For example if you have a user with:

                    Display Name: John Doe, Username: johndoe, Email: johndoe@email.com,

                    you need to write johndoe in this field. Any other value (like display name, or email) will not work.

              • projectKey : String
              • issueType : String
              • autoRaiseIssue : boolean
                Create issues automatically for failing tests that don't yet have one linked.
              • autoResolveIssue : boolean
                Automatically apply transition to resolve issues linked to tests, if the test passes.
                Experimental feature: For now it only looks for the first transition that contains in its name "resolve". If it is found, it will be applied, if not, the status of the issue will not change. In future releases this will be parametrized.
              • autoUnlinkIssue : boolean
              • overrideResolvedIssues : boolean
                Create issues automatically for failing tests that are linked to resolved issues in JiraIssueKeyToTestMap.json.
              • additionalAttachments : boolean (optional)
            • $class: 'JunitResultPublisher'
              If checked, each JUnit test result XML file will be examined to see if it represents a SOASTA CloudTest composition. For applicable tests, a hyperlink to the SOASTA CloudTest dashboard will be inserted into the test report.
              • urlOverride : String
                Specify the CloudTest URL to use when creating hyperlinks to CloudTest dashboards. Normally, this can be left blank, and the URL will be extracted from the test result file.
            • $class: 'PerfSigTestDataPublisher'
              • dynatraceProfile : String
            • $class: 'SahaginTestDataPublishser'
              • $class: 'SauceOnDemandReportPublisher'
                Show embedded Sauce OnDemand reports, including video and logs. Your test should use Selenium client factory (at least version 1.3 to match test cases to individual Sauce OnDemand jobs).
                • jobVisibility : String (optional)
                  Set your test results visibility permissions. The Sauce Documentation has all the various levels described in detail.
              • $class: 'StabilityTestDataPublisher'
                • $class: 'TestCafePublisher'
                  • $class: 'TestReporter'
                    • $class: 'YoutrackTestDataPublisher'

                    step([$class: 'JUnitResultArchiver']): Publish JUnit test result report

                    Jenkins understands the JUnit test report XML format (which is also used by TestNG). When this option is configured, Jenkins can provide useful information about test results, such as historical test result trends, a web UI for viewing test reports, tracking failures, and so on.

                    To use this feature, first set up your build to run tests, then specify the path to JUnit XML files in the Ant glob syntax, such as **/build/test-reports/*.xml. Be sure not to include any non-report files into this pattern. You can specify multiple patterns of files separated by commas.

                    • testResults : String
                    • allowEmptyResults : boolean (optional)
                      If checked, the default behavior of failing a build on missing test result files or empty test results is changed to not affect the status of the build. Please note that this setting make it harder to spot misconfigured jobs or build failures where the test tool does not exit with an error code when not producing test report files.
                    • checksName : String (optional)
                      If provided, and publishing checks enabled, the plugin will use this name when publishing results to corresponding SCM hosting platforms. If not, a default of "Tests" will be used.
                    • healthScaleFactor : double (optional)
                      The amplification factor to apply to test failures when computing the test result contribution to the build health score.
                      The default factor is 1.0
                      • A factor of 0.0 will disable the test result contribution to build health score.
                      • A factor of 0.1 means that 10% of tests failing will score 99% health
                      • A factor of 0.5 means that 10% of tests failing will score 95% health
                      • A factor of 1.0 means that 10% of tests failing will score 90% health
                      • A factor of 2.0 means that 10% of tests failing will score 80% health
                      • A factor of 2.5 means that 10% of tests failing will score 75% health
                      • A factor of 5.0 means that 10% of tests failing will score 50% health
                      • A factor of 10.0 means that 10% of tests failing will score 0% health
                      The factor is persisted with the build results, so changes will only be reflected in new builds.
                    • keepLongStdio : boolean (optional)
                      Deprecated, use stdioRetention instead.

                      If checked, any standard output or error from a test suite will be retained in the test results after the build completes. (This refers only to additional messages printed to console, not to a failure stack trace.) Such output is always kept if the test failed, but by default lengthy output from passing tests is truncated to save space. Check this option if you need to see every log message from even passing tests, but beware that Jenkins's memory consumption can substantially increase as a result, even if you never look at the test results!

                    • keepProperties : boolean (optional)
                    • skipMarkingBuildUnstable : boolean (optional)
                      If this option is unchecked, then the plugin will mark the build as unstable when it finds at least 1 test failure. If this option is checked, then the build will still be successful even if there are test failures reported.
                    • skipOldReports : boolean (optional)
                    • skipPublishingChecks : boolean (optional)
                      If this option is unchecked, then the plugin automatically publishes the test results to corresponding SCM hosting platforms. For example, if you are using this feature for a GitHub organization project, the warnings will be published to GitHub through the Checks API. If this operation slows down your build, or you don't want to publish the warnings to SCM platforms, you can use this option to deactivate this feature.
                    • stdioRetention : String (optional)
                      Controls how standard output or error from a test suite will be retained in the test results after the build completes. (This refers only to additional messages printed to console, not to a failure stack trace.) Some output is always retained for tests, but by default, excessively long output is truncated to save disk space. This property can be used to control whether that truncation takes place:
                      • If set to 'all', then no truncation will take place and the complete output from every test will be stored.
                      • If set to 'failed', then the complete output from all failed tests will be stored, but long output from passing tests will be truncated.
                      • If set to 'none', then long output from every test will be truncated, regardless of whether they passed or failed.
                      Beware that storing large output can cause Jenkins's memory consumption to substantially increase, even if you never look at the test results.
                    • testDataPublishers (optional)
                        Array / List of Nested Choice of Objects
                      • attachments
                        • $class: 'AutomateTestDataPublisher'
                          • $class: 'ClaimTestDataPublisher'
                            • $class: 'JUnitFlakyTestDataPublisher'
                              • jiraTestResultReporter
                                • configs
                                    Array / List of Nested Choice of Objects
                                  • jiraSelectableArrayField
                                    • fieldKey : String
                                    • values
                                        Array / List of Nested Object
                                      • value : String
                                  • jiraSelectableField
                                    • fieldKey : String
                                    • value : String
                                  • jiraStringArrayField
                                    • fieldKey : String
                                    • values
                                        Array / List of Nested Object
                                      • value : String
                                  • jiraStringField
                                    • fieldKey : String
                                    • value : String

                                      Insert a string value.

                                      You can include Jenkins Environment variables (see link), or the following variables defined by this plugin:

                                      Variable usage: ${VAR_NAME}

                                      CRFL - new line

                                      DEFAULT_SUMMARY - configured in the global configuration page

                                      DEFAULT_DESCRIPTION - configured in the global configuration page

                                      TEST_RESULT

                                      TEST_NAME

                                      TEST_FULL_NAME

                                      TEST_STACK_TRACE

                                      TEST_ERROR_DETAILS

                                      TEST_DURATION

                                      TEST_PACKAGE_NAME

                                      TEST_PACKAGE_CLASS_METHOD_NAME

                                      TEST_STDERR

                                      TEST_STDOUT

                                      TEST_OVERVIEW

                                      TEST_AGE

                                      TEST_PASS_COUNT

                                      TEST_SKIPPED_COUNT

                                      TEST_FAIL_SINCE

                                      TEST_IS_REGRESSION - expands to true/false

                                      BUILD_RESULT

                                      WARNING: Your input will not be validated against the server's metadata. Check Jira to make sure you insert a valid value for this field and use the Validate Fields button bellow, otherwise the plugin will fail to create your issue.

                                  • jiraUserField
                                    • fieldKey : String
                                    • value : String

                                      Insert the username.

                                      For example if you have a user with:

                                      Display Name: John Doe, Username: johndoe, Email: johndoe@email.com,

                                      you need to write johndoe in this field. Any other value (like display name, or email) will not work.

                                • projectKey : String
                                • issueType : String
                                • autoRaiseIssue : boolean
                                  Create issues automatically for failing tests that don't yet have one linked.
                                • autoResolveIssue : boolean
                                  Automatically apply transition to resolve issues linked to tests, if the test passes.
                                  Experimental feature: For now it only looks for the first transition that contains in its name "resolve". If it is found, it will be applied, if not, the status of the issue will not change. In future releases this will be parametrized.
                                • autoUnlinkIssue : boolean
                                • overrideResolvedIssues : boolean
                                  Create issues automatically for failing tests that are linked to resolved issues in JiraIssueKeyToTestMap.json.
                                • additionalAttachments : boolean (optional)
                              • $class: 'JunitResultPublisher'
                                If checked, each JUnit test result XML file will be examined to see if it represents a SOASTA CloudTest composition. For applicable tests, a hyperlink to the SOASTA CloudTest dashboard will be inserted into the test report.
                                • urlOverride : String
                                  Specify the CloudTest URL to use when creating hyperlinks to CloudTest dashboards. Normally, this can be left blank, and the URL will be extracted from the test result file.
                              • $class: 'PerfSigTestDataPublisher'
                                • dynatraceProfile : String
                              • $class: 'SahaginTestDataPublishser'
                                • $class: 'SauceOnDemandReportPublisher'
                                  Show embedded Sauce OnDemand reports, including video and logs. Your test should use Selenium client factory (at least version 1.3 to match test cases to individual Sauce OnDemand jobs).
                                  • jobVisibility : String (optional)
                                    Set your test results visibility permissions. The Sauce Documentation has all the various levels described in detail.
                                • $class: 'StabilityTestDataPublisher'
                                  • $class: 'TestCafePublisher'
                                    • $class: 'TestReporter'
                                      • $class: 'YoutrackTestDataPublisher'

                                      Was this page helpful?

                                      Please submit your feedback about this page through this quick form.

                                      Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

                                          


                                      See existing feedback here.