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

Only return names in getStageOrBranchName if it's a stage or branch #253

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

thatsmydoing
Copy link
Contributor

If stageOrBranchName is present, we skip processing errors. This is on the assumption that if stageOrBranchName is present it is a stage or branch. However, normal steps like sh can have labels too and was returned as the stageOrBranchName. This causes labeled steps to not have their errors processed.

We fix this by returning empty in getStageOrBranchName if the node is not a BlockStartNode.

This fixes #252

Testing done

I've tested this on a private Jenkins instance. As far as I can tell, it works as expected. This has no pre-existing tests and I'm honestly not sure how to write them.

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

.orElse(getStageName(node));
if (node instanceof BlockStartNode) {
// a stage or parallel branch must be a BlockStartNode
return getParallelName(node).or(() -> getStageName(node));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be the same as the original code, I've just rewritten it to be more idiomatic.

If `stageOrBranchName` is present, we skip processing errors. This is on
the assumption that if `stageOrBranchName` is present it is a stage or
branch. However, normal steps like `sh` can have labels too and was
returned as the `stageOrBranchName`. This causes labeled steps to not
have their errors processed.

We fix this by returning empty in `getStageOrBranchName` if the node is
not a `BlockStartNode`.
@timja timja added the bug Something isn't working label Mar 18, 2024
@timja timja merged commit fb71c46 into jenkinsci:master Mar 18, 2024
20 checks passed
@thatsmydoing thatsmydoing deleted the labeled-step-error branch October 3, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Steps with labels are not logged as errors
2 participants