Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Jenkins] Add build stages #960

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

phalbert
Copy link
Contributor

@phalbert phalbert commented Aug 28, 2024

Description

  • Added a new kind stage
  • Added a new blueprint jenkinsStage

Implementation

Utilized the Jenkins API provided by the pipeline-stage-view-plugin 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:

{
    "_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.

Type of change

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

  • New feature (non-breaking change which adds functionality)

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

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

  • Integration able to create all default resources from scratch
  • Resync able to create entities
  • Resync able to update entities
  • Resync able to detect and delete entities
  • Resync finishes successfully
  • 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.
  • If resource kind is updated, run the integration with the example data and check if the expected result is achieved
  • If new resource kind is added or updated, validate that live-events for that resource are working as expected
  • Docs PR link here

Preflight checklist

  • Handled rate limiting
  • Handled pagination
  • 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.

@phalbert phalbert requested a review from a team as a code owner August 28, 2024 10:03
@phalbert phalbert self-assigned this Aug 28, 2024
@github-actions github-actions bot added size/L and removed size/M labels Aug 28, 2024
Copy link
Contributor

@PeyGis PeyGis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

integrations/jenkins/CHANGELOG.md Outdated Show resolved Hide resolved
integrations/jenkins/client.py Outdated Show resolved Hide resolved
integrations/jenkins/client.py Outdated Show resolved Hide resolved
integrations/jenkins/client.py Outdated Show resolved Hide resolved
integrations/jenkins/main.py Outdated Show resolved Hide resolved
class JenkinStagesResourceConfig(ResourceConfig):
class JenkinStageSelector(Selector):
query: str
job_url: str = Field(alias="jobUrl", required=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in terms of the user experience, I was just wondering why we're using the job_url instead of the job_name. is the job_url easier or the same as the name? maybe you can share a sample format for the job_url

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of user experience, we use the job_url instead of the job_name primarily for consistency and reliability. Job names can contain spaces or special characters, which require URL encoding, and this can lead to issues if not handled correctly. On the other hand, the job_url is a complete and fully encoded reference to the job, making it more straightforward to work with.

Here are some examples:

http://localhost:8080/job/Phalbert/job/airframe-react/
http://localhost:8080/job/limbopay/job/Limbo%20Core/job/main/

The second url would have the job name Limbo Core in the jenkins dashboard.

In this format, the job_url already includes everything necessary to make API requests (such as appending /api/json), eliminating the need for additional encoding steps. By using job_url, we avoid potential errors related to name encoding and ensure the API calls are more predictable.

After all, the Job URL is always returned as a property and a user can copy and paste in the mapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants