Skip to content

Commit

Permalink
EPMRPP-97271 || Improve Jenkins integration documentation (#840)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuliya_Prihodko <[email protected]>
  • Loading branch information
pressayuliya and Yuliya_Prihodko authored Dec 11, 2024
1 parent 3c34824 commit ac163ee
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions docs/quality-gates/IntegrationWithCICD/IntegrationWithJenkins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ sidebar_label: Integration with Jenkins

# Integration with Jenkins

<MediaViewer src="https://youtu.be/W7BBhni9ANU" alt="Quality Gates in CI/CD and our continuous testing platform" type="video" />
In this article, you will learn how to seamlessly integrate Jenkins into your development workflow.

### Jenkins configuration
## Step 1: Install “Webhook Step” Jenkins plugin

1. Go to “Manage Jenkins” -> “Manage Plugins”.
2. Make sure that the necessary Jenkins plugin is installed:

a. Switch to the “Installed” tab and search for the “Webhook Step” plugin.

b. If no results of the search:

i. Switch to the “Available” tab;

ii. Search for “Webhook Step”;
* Switch to the “Installed” tab and search for the “Webhook Step” plugin.
* If no results of the search:
* Switch to the “Available” tab.
* Search for “Webhook Step”.
* Install the plugin with “Download now and install after restart”.

iii. Install the plugin with “Download now and install after restart”.

3. Define webhook configuration to the Jenkins job/pipeline before tests execution:
## Step 2: Define webhook configuration to the Jenkins job/pipeline before tests execution:

```groovy
def hook = registerWebhook();
Expand All @@ -30,19 +26,31 @@ def encodedUrl = sh(script: "echo -n ${hook.getURL().toString()} | base64 -w 0",

```encodedUrl``` – this is a unique string that will be generated from the Jenkins job/pipeline and connect each reported launch with the appropriate Jenkins run from which the launch was reported.

## Step 3: Run test with webhook

Put the ```encodedUrl``` variable into the test execution string at the enumeration of ```RP.attributes```. For example(Maven build):
Put the ```encodedUrl``` variable into the test execution string at the enumeration of ```RP.attributes```. For example (Maven build):

```groovy
Drp.attributes='k1:v1;k2:v2;rp.webhook.key:${encodedUrl}'
```

5. Configure webhook waiting data from RP:
As result launch with attribute ```rp.webhook.key:${encodedUrl}``` will be reported. On quality gate finish RP will send request to ```{ encodedUrl }``` with quality gate results:

```
{
"launchId": "{launch_id}",
"status": "[PASSED|FAILED|UNDEFINED]"
}
```

Response can be parsed on the next step.

## Step 4: Configure webhook waiting data from RP

**a. Option #1**

This option allows sending the Quality Gates result status to the separate pipeline stage. It doesn’t affect the tests execution stage, and the status of that stage will be determined by the result of the Quality Gate status.
Add additional pipeline stage Wait for webhook and define the particular TIMEOUT_TIME, how long Jenkins should wait for data from RP:
Add additional pipeline stage. Wait for webhook and define the particular TIMEOUT_TIME, how long Jenkins should wait for data from RP:

```groovy
stage('Wait for webhook') {
Expand All @@ -58,7 +66,7 @@ stage('Wait for webhook') {
}
```

Parameters for ```TIMEOUT_TIME``` and ```TIMEOUT_UNIT``` can be defined like that:
Parameters for ```TIMEOUT_TIME``` and ```TIMEOUT_UNIT``` can be defined like that:

```groovy
parameters {
Expand All @@ -69,7 +77,7 @@ parameters {

**b. Option #2**

This option should send the results from the RP to the tests run pipeline stage, and the status of that stage(tests execution) will be determined by the result of the Quality Gate status.
This option should send the results from the RP to the tests run pipeline stage, and the status of that stage (tests execution) will be determined by the result of the Quality Gate status.
Add next code in the pipeline stage, where tests run:

```groovy
Expand All @@ -81,11 +89,13 @@ def jsonData = readJSON text: data
assert jsonData['status'] == 'PASSED'
```

If the Jenkins received a response about QualityGate status from RP, the build status should be appropriately marked:
If the Jenkins received a response about Quality Gate status from RP, the build status should be appropriately marked:

| Jenkins Job Status | Quality Gate Status | Description |
| :----: | :----: | :--- |
| SUCCESS | PASSED | Quality Gate is passed |
| SUCCESS | PASSED | Quality Gate is passed |
| ABORTED | UNDEFINED | The Jenkins timeout has been exceeded |
| FAILED | FAILED | Quality Gate is failed |


<MediaViewer src="https://youtu.be/W7BBhni9ANU" alt="Quality Gates in CI/CD and our continuous testing platform" type="video" />

0 comments on commit ac163ee

Please sign in to comment.