From 6fb5f60699aeb1e3945ccb21b3ae192fe542fba8 Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 28 Aug 2024 12:08:17 +0100 Subject: [PATCH 1/7] Formatting fixes --- .../cicd/jenkins/jenkins.md | 372 +++++++++--------- 1 file changed, 182 insertions(+), 190 deletions(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index 25a44455b..631ba58f2 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -7,9 +7,9 @@ import TabItem from "@theme/TabItem" import Prerequisites from "../../templates/\_ocean_helm_prerequisites_block.mdx" import AzurePremise from "../../templates/\_ocean_azure_premise.mdx" import DockerParameters from "./\_jenkins-docker-parameters.mdx" -import AdvancedConfig from '../../../../generalTemplates/_ocean_advanced_configuration_note.md' -import PortApiRegionTip from "/docs/generalTemplates/_port_region_parameter_explanation_template.md" -import OceanSaasInstallation from "/docs/build-your-software-catalog/sync-data-to-catalog/templates/_ocean_saas_installation.mdx" +import AdvancedConfig from '../../../generalTemplates/\_ocean_advanced_configuration_note.md' +import PortApiRegionTip from "/docs/generalTemplates/\_port_region_parameter_explanation_template.md" +import OceanSaasInstallation from "/docs/build-your-software-catalog/sync-data-to-catalog/templates/\_ocean_saas_installation.mdx" # Jenkins @@ -25,6 +25,7 @@ Our Jenkins integration allows you to import `jobs`, `builds`, and `users` from To generate a token for authenticating the Jenkins API calls: + 1. In the Jenkins banner frame, click your user name to open the user menu. 2. Navigate to Your **Username** > **Configure** > **API Token**. 3. Click Add new Token. @@ -34,12 +35,13 @@ To generate a token for authenticating the Jenkins API calls: :::info Install the People View Plugin -Recent Jenkins versions ([2.452 and above](https://issues.jenkins.io/browse/JENKINS-18884)) no longer include the "People" view by default. This view is essential for providing the user information API that will be queried by the integration. +Recent Jenkins versions ([2.452 and above](https://issues.jenkins.io/browse/JENKINS-18884)) no longer include the "People" view by default. This view is essential for providing the user information API that will be queried by the integration. **To install the plugin:** + - In Jenkins, navigate to **Manage Jenkins** -> **Plugins**. - Search for and install the [**"People View"** plugin](https://plugins.jenkins.io/people-view/). -::: + ::: ## Installation @@ -60,22 +62,21 @@ Using this installation option means that the integration will be able to update This table summarizes the available parameters for the installation. Set them as you wish in the script below, then copy it and run it in your terminal: -| Parameter | Description | Required | -| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------- | -| `port.clientId` | Your port client id ([Get the credentials](https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials)) | ✅ | -| `port.clientSecret` | Your port client secret ([Get the credentials](https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials)) | ✅ | -| `port.baseUrl` | Your Port API URL - `https://api.getport.io` for EU, `https://api.us.getport.io` for US | ✅ | -| `integration.identifier` | Change the identifier to describe your integration | ✅ | -| `integration.type` | The integration type | ✅ | -| `integration.eventListener.type` | The event listener type | ✅ | -| `integration.secrets.jenkinsUser` | The Jenkins username | ✅ | -| `integration.secrets.jenkinsToken` | The Jenkins password or token | ✅ | -| `integration.config.jenkinsHost` | The Jenkins host | ✅ | -| `integration.config.appHost` | The host of the Port Ocean app. Used to set up the integration endpoint as the target for webhooks created in Jenkins | ✅ | -| `scheduledResyncInterval` | The number of minutes between each resync | ❌ | -| `initializePortResources` | Default true, When set to true the integration will create default blueprints and the port App config Mapping | ❌ | -| `sendRawDataExamples` | Enable sending raw data examples from the third party API to port for testing and managing the integration mapping. Default is true | ❌ | - +| Parameter | Description | Required | +| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| `port.clientId` | Your port client id ([Get the credentials](https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials)) | ✅ | +| `port.clientSecret` | Your port client secret ([Get the credentials](https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials)) | ✅ | +| `port.baseUrl` | Your Port API URL - `https://api.getport.io` for EU, `https://api.us.getport.io` for US | ✅ | +| `integration.identifier` | Change the identifier to describe your integration | ✅ | +| `integration.type` | The integration type | ✅ | +| `integration.eventListener.type` | The event listener type | ✅ | +| `integration.secrets.jenkinsUser` | The Jenkins username | ✅ | +| `integration.secrets.jenkinsToken` | The Jenkins password or token | ✅ | +| `integration.config.jenkinsHost` | The Jenkins host | ✅ | +| `integration.config.appHost` | The host of the Port Ocean app. Used to set up the integration endpoint as the target for webhooks created in Jenkins | ❌ | +| `scheduledResyncInterval` | The number of minutes between each resync | ❌ | +| `initializePortResources` | Default true, When set to true the integration will create default blueprints and the port App config Mapping | ❌ | +| `sendRawDataExamples` | Enable sending raw data examples from the third party API to port for testing and managing the integration mapping. Default is true | ❌ |
@@ -98,8 +99,9 @@ helm upgrade --install my-jenkins-integration port-labs/port-ocean \ --set integration.eventListener.type="POLLING" \ --set integration.secrets.jenkinsUser="JENKINS_USER" \ --set integration.secrets.jenkinsToken="JENKINS_TOKEN" \ - --set integration.config.jenkinsHost="JENKINS_HOST" + --set integration.config.jenkinsHost="JENKINS_HOST" ``` + @@ -111,6 +113,7 @@ To install the integration using ArgoCD, follow these steps: :::note Remember to replace the placeholders for `JENKINS_USER`, `JENKINS_TOKEN` and `JENKINS_HOST`. ::: + ```yaml showLineNumbers initializePortResources: true scheduledResyncInterval: 120 @@ -128,6 +131,7 @@ integration: jenkinsToken: JENKINS_TOKEN // highlight-end ``` +
2. Install the `my-ocean-jenkins-integration` ArgoCD Application by creating the following `my-ocean-jenkins-integration.yaml` manifest: @@ -185,9 +189,11 @@ spec:
1. Apply your application manifest with `kubectl`: + ```bash kubectl apply -f my-ocean-jenkins-integration.yaml ``` + @@ -225,8 +231,8 @@ jobs: steps: - uses: port-labs/ocean-sail@v1 - with: - type: 'jenkins' + with: + type: "jenkins" port_client_id: ${{ secrets.OCEAN__PORT__CLIENT_ID }} port_client_secret: ${{ secrets.OCEAN__PORT__CLIENT_SECRET }} port_base_url: https://api.getport.io @@ -309,7 +315,7 @@ Here is an example for `jenkins-integration.yml` pipeline file: ```yaml showLineNumbers trigger: -- main + - main pool: vmImage: "ubuntu-latest" @@ -317,30 +323,28 @@ pool: variables: - group: port-ocean-credentials - steps: -- script: | - # Set Docker image and run the container - integration_type="jenkins" - version="latest" - - image_name="ghcr.io/port-labs/port-ocean-$integration_type:$version" - - docker run -i --rm \ - -e OCEAN__EVENT_LISTENER='{"type":"ONCE"}' \ - -e OCEAN__INITIALIZE_PORT_RESOURCES=true \ - -e OCEAN__SEND_RAW_DATA_EXAMPLES=true \ - -e OCEAN__INTEGRATION__CONFIG__JENKINS_USER=$(OCEAN__INTEGRATION__CONFIG__JENKINS_USER) \ - -e OCEAN__INTEGRATION__CONFIG__JENKINS_TOKEN=$(OCEAN__INTEGRATION__CONFIG__JENKINS_TOKEN) \ - -e OCEAN__INTEGRATION__CONFIG__JENKINS_HOST=$(OCEAN__INTEGRATION__CONFIG__JENKINS_HOST) \ - -e OCEAN__PORT__CLIENT_ID=$(OCEAN__PORT__CLIENT_ID) \ - -e OCEAN__PORT__CLIENT_SECRET=$(OCEAN__PORT__CLIENT_SECRET) \ - -e OCEAN__PORT__BASE_URL='https://api.getport.io' \ - $image_name - - exit $? - displayName: 'Ingest Data into Port' - + - script: | + # Set Docker image and run the container + integration_type="jenkins" + version="latest" + + image_name="ghcr.io/port-labs/port-ocean-$integration_type:$version" + + docker run -i --rm \ + -e OCEAN__EVENT_LISTENER='{"type":"ONCE"}' \ + -e OCEAN__INITIALIZE_PORT_RESOURCES=true \ + -e OCEAN__SEND_RAW_DATA_EXAMPLES=true \ + -e OCEAN__INTEGRATION__CONFIG__JENKINS_USER=$(OCEAN__INTEGRATION__CONFIG__JENKINS_USER) \ + -e OCEAN__INTEGRATION__CONFIG__JENKINS_TOKEN=$(OCEAN__INTEGRATION__CONFIG__JENKINS_TOKEN) \ + -e OCEAN__INTEGRATION__CONFIG__JENKINS_HOST=$(OCEAN__INTEGRATION__CONFIG__JENKINS_HOST) \ + -e OCEAN__PORT__CLIENT_ID=$(OCEAN__PORT__CLIENT_ID) \ + -e OCEAN__PORT__CLIENT_SECRET=$(OCEAN__PORT__CLIENT_SECRET) \ + -e OCEAN__PORT__BASE_URL='https://api.getport.io' \ + $image_name + + exit $? + displayName: "Ingest Data into Port" ``` @@ -358,7 +362,6 @@ Make sure to [configure the following GitLab variables](https://docs.gitlab.com/
- Here is an example for `.gitlab-ci.yml` pipeline file: ```yaml showLineNumbers @@ -368,7 +371,7 @@ default: - docker:24.0.5-dind before_script: - docker info - + variables: INTEGRATION_TYPE: jenkins VERSION: latest @@ -442,15 +445,6 @@ The integration makes use of the [JQ JSON processor](https://stedolan.github.io/ The integration configuration determines which resources will be queried from Jenkins, and which entities and properties will be created in Port. -:::tip Supported resources -The following resources can be used to map data from Jenkins, it is possible to reference any field that appears in the API responses linked below for the mapping configuration. - -- `job` - (`/api/json`) -- `build` - (`/api/json`) -- `user` - (`/people/api/json`) - -::: - - The root key of the integration configuration is the `resources` key: ```yaml showLineNumbers @@ -542,43 +536,38 @@ Examples of blueprints and the relevant integration configurations: "title": "Jenkins Job", "icon": "Jenkins", "schema": { - "properties": { - "jobName": { - "type": "string", - "title": "Job Name" - }, - "jobStatus": { - "type": "string", - "title": "Job Status", - "enum": [ - "created", - "unknown", - "passing", - "failing" - ], - "enumColors": { - "passing": "green", - "created": "darkGray", - "failing": "red", - "unknown": "orange" - } - }, - "timestamp": { - "type": "string", - "format": "date-time", - "title": "Timestamp", - "description": "Last updated timestamp of the job" - }, - "url": { - "type": "string", - "title": "Project URL" - }, - "parentJob": { - "type": "object", - "title": "Parent Job" - } + "properties": { + "jobName": { + "type": "string", + "title": "Job Name" + }, + "jobStatus": { + "type": "string", + "title": "Job Status", + "enum": ["created", "unknown", "passing", "failing"], + "enumColors": { + "passing": "green", + "created": "darkGray", + "failing": "red", + "unknown": "orange" + } + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp", + "description": "Last updated timestamp of the job" }, - "required": [] + "url": { + "type": "string", + "title": "Project URL" + }, + "parentJob": { + "type": "object", + "title": "Parent Job" + } + }, + "required": [] }, "mirrorProperties": {}, "calculationProperties": {}, @@ -625,62 +614,66 @@ resources: "description": "This blueprint represents a build event from Jenkins", "title": "Jenkins Build", "icon": "Jenkins", - "schema": { - "properties": { - "buildStatus": { + "schema": + { + "properties": + { + "buildStatus": + { "type": "string", "title": "Build Status", - "enum": [ - "SUCCESS", - "FAILURE", - "UNSTABLE" - ], - "enumColors": { - "SUCCESS": "green", - "FAILURE": "red", - "UNSTABLE": "yellow" - } - }, - "buildUrl": { + "enum": ["SUCCESS", "FAILURE", "UNSTABLE"], + "enumColors": + { "SUCCESS": "green", "FAILURE": "red", "UNSTABLE": "yellow" }, + }, + "buildUrl": + { "type": "string", "title": "Build URL", - "description": "URL to the build" - }, - "timestamp": { + "description": "URL to the build", + }, + "timestamp": + { "type": "string", "format": "date-time", "title": "Timestamp", - "description": "Last updated timestamp of the build" - }, - "buildDuration": { + "description": "Last updated timestamp of the build", + }, + "buildDuration": + { "type": "number", "title": "Build Duration", - "description": "Duration of the build" - } - }, - "required": [] - }, - "mirrorProperties": { - "previousBuildStatus": { + "description": "Duration of the build", + }, + }, + "required": [], + }, + "mirrorProperties": + { + "previousBuildStatus": + { "title": "Previous Build Status", - "path": "previousBuild.buildStatus" - } - }, + "path": "previousBuild.buildStatus", + }, + }, "calculationProperties": {}, - "relations": { - "parentJob": { + "relations": + { + "parentJob": + { "title": "Jenkins Job", "target": "jenkinsJob", "required": false, - "many": false - }, - "previousBuild": { + "many": false, + }, + "previousBuild": + { "title": "Previous Build", "target": "jenkinsBuild", "required": false, - "many": false - } - } + "many": false, + }, + }, } ``` @@ -706,7 +699,7 @@ resources: buildStatus: .result buildUrl: .url buildDuration: .duration - timestamp: '.timestamp / 1000 | todate' + timestamp: ".timestamp / 1000 | todate" relations: parentJob: .url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("/"; "-") | .[:-1] | gsub("-[0-9]+$"; "") previousBuild: .previousBuild.url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("/"; "-") | .[:-1] @@ -714,7 +707,6 @@ resources: - ### User
@@ -727,20 +719,20 @@ resources: "title": "Jenkins User", "icon": "Jenkins", "schema": { - "properties": { - "url": { - "type": "string", - "title": "URL", - "format": "url" - }, - "lastUpdateTime": { - "type": "string", - "format": "date-time", - "title": "Last Update", - "description": "Last updated timestamp of the user" - } + "properties": { + "url": { + "type": "string", + "title": "URL", + "format": "url" }, - "required": [] + "lastUpdateTime": { + "type": "string", + "format": "date-time", + "title": "Last Update", + "description": "Last updated timestamp of the user" + } + }, + "required": [] }, "mirrorProperties": {}, "calculationProperties": {}, @@ -787,37 +779,37 @@ Here is an example of the payload structure from Jenkins: ```json showLineNumbers { - "_class" : "hudson.model.FreeStyleProject", - "displayName" : "Hello Job", - "fullName" : "Hello Job", - "name" : "Hello Job", - "url" : "http://localhost:8080/job/Hello%20Job/", - "buildable" : true, - "builds" : [ + "_class": "hudson.model.FreeStyleProject", + "displayName": "Hello Job", + "fullName": "Hello Job", + "name": "Hello Job", + "url": "http://localhost:8080/job/Hello%20Job/", + "buildable": true, + "builds": [ { - "_class" : "hudson.model.FreeStyleBuild", - "displayName" : "#2", - "duration" : 221, - "fullDisplayName" : "Hello Job #2", - "id" : "2", - "number" : 2, - "result" : "SUCCESS", - "timestamp" : 1700569094576, - "url" : "http://localhost:8080/job/Hello%20Job/2/" + "_class": "hudson.model.FreeStyleBuild", + "displayName": "#2", + "duration": 221, + "fullDisplayName": "Hello Job #2", + "id": "2", + "number": 2, + "result": "SUCCESS", + "timestamp": 1700569094576, + "url": "http://localhost:8080/job/Hello%20Job/2/" }, { - "_class" : "hudson.model.FreeStyleBuild", - "displayName" : "#1", - "duration" : 2214, - "fullDisplayName" : "Hello Job #1", - "id" : "1", - "number" : 1, - "result" : "SUCCESS", - "timestamp" : 1700567994163, - "url" : "http://localhost:8080/job/Hello%20Job/1/" + "_class": "hudson.model.FreeStyleBuild", + "displayName": "#1", + "duration": 2214, + "fullDisplayName": "Hello Job #1", + "id": "1", + "number": 1, + "result": "SUCCESS", + "timestamp": 1700567994163, + "url": "http://localhost:8080/job/Hello%20Job/1/" } ], - "color" : "blue" + "color": "blue" } ``` @@ -828,15 +820,15 @@ Here is an example of the payload structure from Jenkins: ```json showLineNumbers { - "_class" : "hudson.model.FreeStyleBuild", - "displayName" : "#2", - "duration" : 221, - "fullDisplayName" : "Hello Job #2", - "id" : "2", - "number" : 2, - "result" : "SUCCESS", - "timestamp" : 1700569094576, - "url" : "http://localhost:8080/job/Hello%20Job/2/" + "_class": "hudson.model.FreeStyleBuild", + "displayName": "#2", + "duration": 221, + "fullDisplayName": "Hello Job #2", + "id": "2", + "number": 2, + "result": "SUCCESS", + "timestamp": 1700569094576, + "url": "http://localhost:8080/job/Hello%20Job/2/" } ``` @@ -847,13 +839,13 @@ Here is an example of the payload structure from Jenkins: ```json showLineNumbers { - "user" : { - "absoluteUrl" : "http://localhost:8080/user/admin", - "fullName" : "admin", - "description" : "System Administrator", - "id" : "admin" + "user": { + "absoluteUrl": "http://localhost:8080/user/admin", + "fullName": "admin", + "description": "System Administrator", + "id": "admin" }, - "lastChange" : 1700569094576 + "lastChange": 1700569094576 } ``` From f31f0fc9a504d77e41299080a0dbe7b59043df5b Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 28 Aug 2024 12:22:40 +0100 Subject: [PATCH 2/7] [Ocean][Jenkins] Add stage kind --- .../cicd/jenkins/jenkins.md | 171 +++++++++++++++++- 1 file changed, 162 insertions(+), 9 deletions(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index 631ba58f2..03f41ad64 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -13,11 +13,11 @@ import OceanSaasInstallation from "/docs/build-your-software-catalog/sync-data-t # Jenkins -Our Jenkins integration allows you to import `jobs`, `builds`, and `users` from your Jenkins environment into Port, according to your mapping and definitions. +Our Jenkins integration allows you to import `jobs`, `builds`, `stages`, and `users` from your Jenkins environment into Port, according to your mapping and definitions. ## Common use cases -- Map `jobs`, `builds`, and `users` in your Jenkins environment. +- Map `jobs`, `builds`, `stages`, and `users` in your Jenkins environment. - Watch for object changes (create/update/delete) in real-time, and automatically apply the changes to your entities in Port. ## Prerequisites @@ -25,6 +25,7 @@ Our Jenkins integration allows you to import `jobs`, `builds`, and `users` from To generate a token for authenticating the Jenkins API calls: + 1. In the Jenkins banner frame, click your user name to open the user menu. 2. Navigate to Your **Username** > **Configure** > **API Token**. @@ -32,16 +33,20 @@ To generate a token for authenticating the Jenkins API calls: 4. Click Generate. 5. Copy the API token that is generated to use as the `JENKINS_TOKEN`. - -:::info Install the People View Plugin -Recent Jenkins versions ([2.452 and above](https://issues.jenkins.io/browse/JENKINS-18884)) no longer include the "People" view by default. This view is essential for providing the user information API that will be queried by the integration. +:::info Install Required Plugins +To ensure full functionality of the Jenkins integration, please install the following plugins: -**To install the plugin:** +1. **People View Plugin**: Required for user information API (for Jenkins versions 2.452 and above) + - Navigate to **Manage Jenkins** -> **Plugins** + - Search for and install the [**"People View"** plugin](https://plugins.jenkins.io/people-view/) -- In Jenkins, navigate to **Manage Jenkins** -> **Plugins**. -- Search for and install the [**"People View"** plugin](https://plugins.jenkins.io/people-view/). - ::: +2. **Pipeline: Stage View Plugin**: Required for fetching stages data + - Navigate to **Manage Jenkins** -> **Plugins** + - Search for and install the [**"Pipeline: Stage View"** plugin](https://plugins.jenkins.io/pipeline-stage-view/) + +These plugins are essential for the integration to access user information and pipeline stage data. +::: ## Installation @@ -766,6 +771,99 @@ resources:
+ +### Stage + +
+Stage blueprint + +```json showLineNumbers +{ + "identifier": "jenkinsStage", + "description": "This blueprint represents a stage in a Jenkins build", + "title": "Jenkins Stage", + "icon": "Jenkins", + "schema": { + "properties": { + "status": { + "type": "string", + "title": "Stage Status", + "enum": [ + "SUCCESS", + "FAILURE", + "UNSTABLE", + "ABORTED", + "IN_PROGRESS", + "NOT_BUILT", + "PAUSED_PENDING_INPUT" + ], + "enumColors": { + "SUCCESS": "green", + "FAILURE": "red", + "UNSTABLE": "yellow", + "ABORTED": "darkGray", + "IN_PROGRESS": "blue", + "NOT_BUILT": "lightGray", + "PAUSED_PENDING_INPUT": "orange" + } + }, + "startTimeMillis": { + "type": "number", + "title": "Start Time (ms)", + "description": "Timestamp in milliseconds when the stage started" + }, + "durationMillis": { + "type": "number", + "title": "Duration (ms)", + "description": "Duration of the stage in milliseconds" + }, + "stageUrl": { + "type": "string", + "title": "Stage URL", + "description": "URL to the stage" + } + }, + "required": [] + }, + "mirrorProperties": {}, + "calculationProperties": {}, + "relations": { + "parentBuild": { + "title": "Jenkins Build", + "target": "jenkinsBuild", + "required": true, + "many": false + } + } +} +``` + +
+ +
+Integration configuration + +```yaml showLineNumbers +- kind: stage + selector: + query: 'true' + port: + entity: + mappings: + identifier: '._links.self.href | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-")' + title: .name + blueprint: '"jenkinsStage"' + properties: + status: .status + startTimeMillis: .startTimeMillis + durationMillis: .durationMillis + stageUrl: '.__fullUrl' + relations: + parentBuild: '._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-")' +``` + +
+ ## Let's Test It This section includes a sample response data from Jenkins. In addition, it includes the entity created from the resync event based on the Ocean configuration provided in the previous section. @@ -851,6 +949,33 @@ Here is an example of the payload structure from Jenkins: +
+Stage response data + +:::tip +The `__fullUrl` is an enrichment field that is automatically added to the response data. It is used to store the full URL of the stage. +::: + +```json showLineNumbers +{ + "_links": { + "self": { + "href": "/job/Phalbert/job/salesdash/job/master/227/execution/node/17/wfapi/describe" + } + }, + "id": "17", + "name": "Declarative: Post Actions", + "execNode": "", + "status": "SUCCESS", + "startTimeMillis": 1717073271079, + "durationMillis": 51, + "pauseDurationMillis": 0, + "__fullUrl": "http://localhost:8080/job/Phalbert/job/salesdash/job/master/227/execution/node/17/wfapi/describe" +} +``` + +
+ ### Mapping Result The combination of the sample payload and the Ocean configuration generates the following Port entity: @@ -926,3 +1051,31 @@ The combination of the sample payload and the Ocean configuration generates the ``` + +
+Stage entity + +```json showLineNumbers +{ + "identifier": "job-Phalbert-job-salesdash-job-master-229-execution-node-17-wfapi-describe", + "title": "Declarative: Post Actions", + "icon": null, + "blueprint": "jenkinsStage", + "team": [], + "properties": { + "status": "SUCCESS", + "startTimeMillis": 1717073272012, + "durationMillis": 26, + "stageUrl": "http://localhost:8080/job/Phalbert/job/salesdash/job/master/229/execution/node/17/wfapi/describe" + }, + "relations": { + "parentBuild": "job-Phalbert-job-salesdash-job-master-229" + }, + "createdAt": "2024-08-28T10:27:33.549Z", + "createdBy": "", + "updatedAt": "2024-08-28T10:27:30.274Z", + "updatedBy": "" +} +``` + +
From cf84314d4c001587673967146aa89747f9612c07 Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 28 Aug 2024 17:00:00 +0100 Subject: [PATCH 3/7] Update jenkins.md --- .../sync-data-to-catalog/cicd/jenkins/jenkins.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index 03f41ad64..d60f5e966 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -952,10 +952,6 @@ Here is an example of the payload structure from Jenkins:
Stage response data -:::tip -The `__fullUrl` is an enrichment field that is automatically added to the response data. It is used to store the full URL of the stage. -::: - ```json showLineNumbers { "_links": { @@ -969,8 +965,7 @@ The `__fullUrl` is an enrichment field that is automatically added to the respon "status": "SUCCESS", "startTimeMillis": 1717073271079, "durationMillis": 51, - "pauseDurationMillis": 0, - "__fullUrl": "http://localhost:8080/job/Phalbert/job/salesdash/job/master/227/execution/node/17/wfapi/describe" + "pauseDurationMillis": 0 } ``` From 2ca7ac81cd9bf0244a6112f589bbdbcb79851a0b Mon Sep 17 00:00:00 2001 From: PagesCoffy Date: Wed, 28 Aug 2024 11:48:19 +0000 Subject: [PATCH 4/7] Update docs/build-your-software-catalog/sync-data-to-catalog/jenkins/jenkins.md --- .../sync-data-to-catalog/cicd/jenkins/jenkins.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index d60f5e966..e60a26d6a 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -13,7 +13,8 @@ import OceanSaasInstallation from "/docs/build-your-software-catalog/sync-data-t # Jenkins -Our Jenkins integration allows you to import `jobs`, `builds`, `stages`, and `users` from your Jenkins environment into Port, according to your mapping and definitions. +Port's Jenkins integration allows you to import `jobs`, `builds`, `stages`, and `users` from your Jenkins environment into Port, according to your mapping and definitions. + ## Common use cases From b6b21293fbb86636e7da9a8c40ae0699e0b1a8c9 Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 25 Sep 2024 11:15:40 +0100 Subject: [PATCH 5/7] Update jenkins.md --- .../cicd/jenkins/jenkins.md | 86 +++++++++++++++---- 1 file changed, 71 insertions(+), 15 deletions(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index e60a26d6a..64216183e 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -844,23 +844,79 @@ resources:
Integration configuration +:::note Control Stage Fetching +To prevent overwhelming your Ocean instance with potentially thousands of stages from Jenkins, the integration requires you to specify a specific job. This ensures that Ocean only retrieves stages related to that job, keeping things focused and efficient. + +**Important**: The integration will also fetch stages from all nested jobs within the specified job. +::: + ```yaml showLineNumbers - kind: stage - selector: - query: 'true' - port: - entity: - mappings: - identifier: '._links.self.href | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-")' - title: .name - blueprint: '"jenkinsStage"' - properties: - status: .status - startTimeMillis: .startTimeMillis - durationMillis: .durationMillis - stageUrl: '.__fullUrl' - relations: - parentBuild: '._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-")' + selector: + query: 'true' + jobUrl: http://localhost:8080/job/limbopay/job/Limbo%20Core/job/main + port: + entity: + mappings: + identifier: >- + ._links.self.href | sub("^.*?/"; "") | gsub("%20"; "-") | + gsub("%252F"; "-") | gsub("/"; "-") + title: .name + blueprint: '"jenkinsStage"' + properties: + status: .status + startTimeMillis: .startTimeMillis + durationMillis: .durationMillis + stageUrl: env.OCEAN__INTEGRATION__CONFIG__JENKINS_HOST + ._links.self.href + relations: + parentBuild: >- + ._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; + "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | + gsub("/"; "-") +- kind: stage + selector: + query: 'true' + jobUrl: http://localhost:8080/job/Phalbert/job/airframe-react + port: + entity: + mappings: + identifier: >- + ._links.self.href | sub("^.*?/"; "") | gsub("%20"; "-") | + gsub("%252F"; "-") | gsub("/"; "-") + title: .name + blueprint: '"jenkinsStage"' + properties: + status: .status + startTimeMillis: .startTimeMillis + durationMillis: .durationMillis + stageUrl: env.OCEAN__INTEGRATION__CONFIG__JENKINS_HOST + ._links.self.href + relations: + parentBuild: >- + ._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; + "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | + gsub("/"; "-") +- kind: stage + selector: + query: 'true' + jobUrl: http://localhost:8080/job/Phalbert/job/autoshop_api + port: + entity: + mappings: + identifier: >- + ._links.self.href | sub("^.*?/"; "") | gsub("%20"; "-") | + gsub("%252F"; "-") | gsub("/"; "-") + title: .name + blueprint: '"jenkinsStage"' + properties: + status: .status + startTimeMillis: .startTimeMillis + durationMillis: .durationMillis + stageUrl: env.OCEAN__INTEGRATION__CONFIG__JENKINS_HOST + ._links.self.href + relations: + parentBuild: >- + ._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; + "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | + gsub("/"; "-") ```
From afabaa837a473b17c355ca538da85e04a1ae0101 Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 25 Sep 2024 11:31:22 +0100 Subject: [PATCH 6/7] Update jenkins.md --- .../sync-data-to-catalog/cicd/jenkins/jenkins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index 64216183e..6e75e192b 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -7,7 +7,7 @@ import TabItem from "@theme/TabItem" import Prerequisites from "../../templates/\_ocean_helm_prerequisites_block.mdx" import AzurePremise from "../../templates/\_ocean_azure_premise.mdx" import DockerParameters from "./\_jenkins-docker-parameters.mdx" -import AdvancedConfig from '../../../generalTemplates/\_ocean_advanced_configuration_note.md' +import AdvancedConfig from "/docs/generalTemplates/\_ocean_advanced_configuration_note.md" import PortApiRegionTip from "/docs/generalTemplates/\_port_region_parameter_explanation_template.md" import OceanSaasInstallation from "/docs/build-your-software-catalog/sync-data-to-catalog/templates/\_ocean_saas_installation.mdx" From bfaa3a416e1e36abbb8fca50b315ceef38427b96 Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 25 Sep 2024 15:12:40 +0100 Subject: [PATCH 7/7] Update jenkins.md --- .../sync-data-to-catalog/cicd/jenkins/jenkins.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md index 6e75e192b..59ed5bc23 100644 --- a/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md +++ b/docs/build-your-software-catalog/sync-data-to-catalog/cicd/jenkins/jenkins.md @@ -769,7 +769,6 @@ resources: lastUpdateTime: if .lastChange then (.lastChange/1000) else now end | strftime("%Y-%m-%dT%H:%M:%SZ") ``` -
@@ -854,7 +853,8 @@ To prevent overwhelming your Ocean instance with potentially thousands of stages - kind: stage selector: query: 'true' - jobUrl: http://localhost:8080/job/limbopay/job/Limbo%20Core/job/main + # Example jobUrl - replace with your own Jenkins job URL + jobUrl: http://your-jenkins-server/job/your-project/job/your-job port: entity: mappings: @@ -873,10 +873,15 @@ To prevent overwhelming your Ocean instance with potentially thousands of stages ._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-") + +# Additional stage configurations follow the same pattern. +# Make sure to replace the jobUrl with your own Jenkins job URLs for each configuration. + - kind: stage selector: query: 'true' - jobUrl: http://localhost:8080/job/Phalbert/job/airframe-react + # Example jobUrl - replace with your own Jenkins job URL + jobUrl: http://your-jenkins-server/job/your-project/job/another-job port: entity: mappings: @@ -895,10 +900,12 @@ To prevent overwhelming your Ocean instance with potentially thousands of stages ._links.self.href | sub("/execution/node/[0-9]+/wfapi/describe$"; "") | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-") + - kind: stage selector: query: 'true' - jobUrl: http://localhost:8080/job/Phalbert/job/autoshop_api + # Example jobUrl - replace with your own Jenkins job URL + jobUrl: http://your-jenkins-server/job/your-project/job/third-job port: entity: mappings: