Skip to content

Commit

Permalink
[Jenkins] Add build stages (#960)
Browse files Browse the repository at this point in the history
# Description

- Added a new kind `stage`
- Added a new blueprint `jenkinsStage`

### Implementation
Utilized the Jenkins API provided by the
[pipeline-stage-view-plugin](https://github.com/jenkinsci/pipeline-stage-view-plugin/tree/master/rest-api#get-jobjob-namewfapiruns)
to retrieve pipeline stage information.

The API returns details such as stage IDs, names, statuses, start times,
durations, and links to each stage, as shown in the example JSON
response below:

```json
{
    "_links": {
        "self": {
            "href": "/job/Phalbert/job/airframe-react/job/master/29/wfapi/describe"
        }
    },
    "id": "29",
    "name": "#29",
    "status": "FAILED",
    "startTimeMillis": 1717069181870,
    "endTimeMillis": 1717070384780,
    "durationMillis": 1202910,
    "queueDurationMillis": 5,
    "pauseDurationMillis": 0,
    "stages": [
        {
            "_links": {
                "self": {
                    "href": "/job/Phalbert/job/airframe-react/job/master/29/execution/node/6/wfapi/describe"
                }
            },
            "id": "6",
            "name": "Declarative: Checkout SCM",
            "execNode": "",
            "status": "SUCCESS",
            "startTimeMillis": 1717070383791,
            "durationMillis": 892,
            "pauseDurationMillis": 0
        },
        {
            "_links": {
                "self": {
                    "href": "/job/Phalbert/job/airframe-react/job/master/29/execution/node/17/wfapi/describe"
                }
            },
            "id": "17",
            "name": "Declarative: Post Actions",
            "execNode": "",
            "status": "SUCCESS",
            "startTimeMillis": 1717070384739,
            "durationMillis": 24,
            "pauseDurationMillis": 0
        }
    ]
}
```

Additional Context: For more details and ongoing discussion, please
refer to the linked Slack thread: [Jira Task
Discussion](https://getport.slack.com/archives/C0799SR843F/p1723749916041039).

## Type of change

Please leave one option from the following and delete the rest:

- [x] New feature (non-breaking change which adds functionality)

<h4> All tests should be run against the port production
environment(using a testing org). </h4>

### Core testing checklist

- [ ] Integration able to create all default resources from scratch
- [ ] Resync finishes successfully
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Scheduled resync able to abort existing resync and start a new one
- [ ] Tested with at least 2 integrations from scratch
- [ ] Tested with Kafka and Polling event listeners


### Integration testing checklist

- [x] Integration able to create all default resources from scratch
- [x] Resync able to create entities
- [x] Resync able to update entities
- [x] Resync able to detect and delete entities
- [x] Resync finishes successfully
- [x] If new resource kind is added or updated in the integration, add
example raw data, mapping and expected result to the `examples` folder
in the integration directory.
- [x] If resource kind is updated, run the integration with the example
data and check if the expected result is achieved
- [x] If new resource kind is added or updated, validate that
live-events for that resource are working as expected
- [x] Docs PR link
[here](port-labs/port-docs#1613)

### Preflight checklist

- [x] Handled rate limiting
- [x] Handled pagination
- [x] Implemented the code in async
- [ ] Support Multi account

## Screenshots

Include screenshots from your environment showing how the resources of
the integration will look.

## API Documentation

Provide links to the API documentation used for this integration.

---------

Co-authored-by: PagesCoffy <isaac.p.coffie@gmail.com>
Co-authored-by: omby8888 <160610297+omby8888@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 7, 2024
1 parent ed86f24 commit eca71f8
Show file tree
Hide file tree
Showing 15 changed files with 476 additions and 74 deletions.
6 changes: 4 additions & 2 deletions integrations/jenkins/.port/resources/blueprints.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@
"enum": [
"SUCCESS",
"FAILURE",
"UNSTABLE"
"UNSTABLE",
"ABORTED"
],
"enumColors": {
"SUCCESS": "green",
"FAILURE": "red",
"UNSTABLE": "yellow"
"UNSTABLE": "yellow",
"ABORTED": "darkGray"
}
},
"buildUrl": {
Expand Down
8 changes: 4 additions & 4 deletions integrations/jenkins/.port/resources/port-app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resources:
port:
entity:
mappings:
identifier: .url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("/"; "-") | .[:-1]
identifier: .url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-") | .[:-1]
title: .fullName
blueprint: '"jenkinsJob"'
properties:
Expand All @@ -22,7 +22,7 @@ resources:
port:
entity:
mappings:
identifier: .url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("/"; "-") | .[:-1]
identifier: .url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-") | .[:-1]
title: .displayName
blueprint: '"jenkinsBuild"'
properties:
Expand All @@ -31,8 +31,8 @@ resources:
buildDuration: .duration
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]
parentJob: .url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-") | .[:-1] | gsub("-[0-9]+$"; "")
previousBuild: .previousBuild.url | split("://")[1] | sub("^.*?/"; "") | gsub("%20"; "-") | gsub("%252F"; "-") | gsub("/"; "-") | .[:-1]
- kind: user
selector:
query: "true"
Expand Down
1 change: 1 addition & 0 deletions integrations/jenkins/.port/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ features:
- kind: job
- kind: build
- kind: user
- kind: stage
configurations:
- name: jenkinsHost
description: The base URL of your Jenkins server. This should be the address you use to access the Jenkins dashboard in your browser (e.g., "https://your-jenkins-server.com").
Expand Down
Loading

0 comments on commit eca71f8

Please sign in to comment.