diff --git a/docs/quality-gates/IntegrationWithCICD/IntegrationWithJenkins.mdx b/docs/quality-gates/IntegrationWithCICD/IntegrationWithJenkins.mdx index ba123a733..11c9fa67e 100644 --- a/docs/quality-gates/IntegrationWithCICD/IntegrationWithJenkins.mdx +++ b/docs/quality-gates/IntegrationWithCICD/IntegrationWithJenkins.mdx @@ -4,24 +4,20 @@ sidebar_label: Integration with Jenkins # Integration with Jenkins - +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(); @@ -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') { @@ -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 { @@ -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 @@ -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 | + +