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

Add link to agent a stage is running on to stage summary #495

Merged
merged 13 commits into from
Nov 14, 2024

Conversation

Hammie
Copy link
Contributor

@Hammie Hammie commented Sep 2, 2024

Adds a line to the console view stage summary, showing which agent the stage is running on.

Fixes #426

Testing done

Ran the plugin on a Jenkins instance with multi-stage pipelines, and so far everything seems to work.

jenkins_pipeline_agent

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Sorry, something went wrong.

@Hammie Hammie requested a review from a team as a code owner September 2, 2024 13:36
@timja timja added the enhancement New feature or request label Sep 3, 2024
@KalleOlaviNiemitalo
Copy link

What does this render if the pipeline has agent none and there is no agent for the stage either? We have some pipelines like that, where an agentless stage sets job properties conditionally before the job starts waiting for an available agent.

@timja
Copy link
Member

timja commented Sep 3, 2024

What does this render if the pipeline has agent none and there is no agent for the stage either? We have some pipelines like that, where an agentless stage sets job properties conditionally before the job starts waiting for an available agent.

Good find, there's a bug it always displays the text when it should only do it if the agent is running on a stage:

image

@Hammie
Copy link
Contributor Author

Hammie commented Sep 3, 2024

I've also been testing it on our production instance, and there are some more edge cases where it is not quite working as expected.

  • A parallel stage copies the agent property from its first child stage
  • A simple single-stage pipeline also shows no agent (even when already running)

I'll try and fix these and also write some tests for them so we can have some confidence in it working well.

But I'm not an experienced Java dev, so we'll see how that goes...

@Hammie
Copy link
Contributor Author

Hammie commented Sep 20, 2024

I've added some tests and fixed the known issues.

Not really happy with the actual agent lookup code, but I don't think I can really do it better.

At the very least the tests should make it easier if someone wants to try and rewrite it.

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Code looks pretty good from a read, one improvement needed and I'll do a re-test when I get a chance

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

The link I am currently getting when I click to view the agent is:
http://localhost:8085/jenkins/job/junit-attachments-test/job/master/31/pipeline-console/undefined/computer/(built-in)/

(with undefined in the url) and the link doesn't work

}

const StageNodeLink = ({agent}: StageNodeLinkProps) => {
const agentName = agent == "built-in" ? "Jenkins" : agent;
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't seem to be working the agent name is coming through as jenkins and not Jenkins:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess jenkins is also fine. What does the link say? (built-in) or also jenkins?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Problem was the capitalize css class applied to it.

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

LGTM thanks for your work on this!

@timja timja merged commit 81e4460 into jenkinsci:main Nov 14, 2024
17 checks passed
@Hammie Hammie deleted the feature/stage-agent-info branch November 14, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show agent on pipeline console stage summary
3 participants