You can use a test task to test a deployment. When you register a Jenkins Server endpoint, you connect to a Jenkins server to start a build job from a release pipeline.

About this task

Note:

If you have existing artifacts in the Jenkins server you cannot access them from vRealize Code Stream.

If you configure a Jenkins test job to fail if test failures occur, then the release pipeline also fails.

Prerequisites

  • Verify that the Jenkins server endpoint is registered. See the Installation and Configuration guide.

  • Verify that the Jenkins server version is 1.561 or later.

Procedure

  1. Click the Code Stream tab.
  2. On the Pipelines tab, select an existing pipeline and click Edit to configure it.
  3. Click the Stages > button.
  4. Click Add Task.
  5. Select Jenkins from the Provider drop-down menu.
  6. Enter a name for the test task and click OK.
  7. Select the new task in the stage.
  8. Confirm to save the pipeline.
  9. Select an Execute Task for the release pipeline.

    Option

    Description

    Always

    Runs the release pipeline task without conditions.

    On Condition(s)

    Runs the release pipeline task only if the defined condition is evaluated as true. If the condition is false, the task is skipped.

    A boolean expression using the following operands and operators is supported.

    • Pipeline variables such as, ${pipeline.variableName}. Curly brackets are reserved for specifying pipeline variables.

    • Task output variables such as, ${Stage1.task1.machines[0].value.hostIp[0]}

    • Default pipeline binding variables such as, ${releasePipelineName}

    • Case insensitive Boolean values such as, true, false, 'true', 'false'

    • Integer or decimal values without quotes

    • String values used with single or double quotes such as, "test", 'test'

    • String and Numeric types of values such as, == Equals and != Not Equals

    • Relational operators such as, > , >=, <, and <=

    • Boolean logic such as, && and ||

    • Arithmetic operators such as, +, -, *, and /

    • Nested expressions using round brackets

    • Strings with literal value ABCD is evaluated as false and the task is skipped.

    Unary operators are not supported.

    A sample condition, ${Stage1.task1.output} == “Passed” || ${pipeline.variableName} == 39

  10. (Optional) : Select the Continue Pipeline execution even if this task fails option.

    This option allows the release pipeline to bypass the failed task and continue with the execution process.

  11. Select the Jenkins job from the Jobs drop-down menu.
  12. Select the Jenkins server endpoint you registered from the drop-down menu.
  13. Enter the Jenkins job input properties.
    1. Click the text box and enter ${.

      The associated variables appear in the drop-down menu.

    2. Select the variable.
    3. (Optional) : Enter a period next to the variable to view the task name in the drop-down menu.
    4. (Optional) : Enter a period next to the task name to view the task output or pipeline parameters in the drop-down menu.

    For example, the input property variable can be ${StageName.test.JobName}.

  14. Click Save.

Output Format for a Jenkins Task

The following task output format is an example for a test task.

[
        {
            "name": "buildId",
            "type": "STRING",
            "description": "Build Id",
            "value": "4"
        },
        {
            "name": "jobUrl",
            "type": "STRING",
            "description": "Job Url",
            "value": "http://198.51.100.13:8080/job/dummy/4"
        },
        {
            "name": "estimatedDuration",
            "type": "NUMBER",
            "description": "Estimation time to complete the build",
            "value": "2332343"
        },
        {
            "name": "jobName",
            "type": "STRING",
            "description": "Job Name",
            "value": "dummy"
        },
        {
            "name": "testResult",
            "type": "JSON",
            "description": "Job Name",
            "value": {
                "totalCount": 40,
                "skipCount": 0,
                "failureCount": 0,
                "successCount": 40
            }
        }
    ]