Skip to content

log appropriate error messages to build console#759

Merged
rantoniuk merged 33 commits intomasterfrom
rantoniuk/pickup-771
Nov 25, 2025
Merged

log appropriate error messages to build console#759
rantoniuk merged 33 commits intomasterfrom
rantoniuk/pickup-771

Conversation

@rantoniuk
Copy link
Member

@rantoniuk rantoniuk commented Nov 25, 2025

Pick up #711 by @Hardikrathod01 and resolve conflicts.

Related issues

#702
#711

Changes

See #711

Tests

  • I have tested my changes with a Jira Cloud
  • I have verified that the Code Coverage is not lower than before / that all the changes are covered as needed

Checklist

  • Make sure you are requesting the pull request from a custom branch and not your master/main branch
  • Ensure that the pull request title represents the desired changelog entry
  • Apply relevant PR labels, at least one of feature or bugfix or documentation

Hardik Rathod and others added 30 commits June 17, 2025 14:08
…es' into issue_702_log_appropriate_messages
- Catch specific exceptions rather than catching general Exception
…essages

* master:
  Bump org.jenkins-ci.plugins:plugin from 5.26 to 5.28 in the jenkins group (#753)
@rantoniuk rantoniuk requested a review from a team as a code owner November 25, 2025 13:05
Copilot AI review requested due to automatic review settings November 25, 2025 13:05
@rantoniuk rantoniuk enabled auto-merge (squash) November 25, 2025 13:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves error handling and logging by replacing TimeoutException with RestClientException throughout the JIRA plugin, ensuring that appropriate error messages are logged to the build console when REST API calls fail.

Key Changes:

  • Replaced TimeoutException with RestClientException in method signatures and exception handling across the codebase
  • Added try-catch blocks in pipeline steps and build steps to catch RestClientException and log error messages to the build console
  • Modified JiraRestService to throw RestClientException with descriptive messages instead of returning null or empty collections on errors

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/main/java/hudson/plugins/jira/JiraRestService.java Core change: throws RestClientException with descriptive messages instead of returning null/empty collections
src/main/java/hudson/plugins/jira/JiraSession.java Updated method signatures to throw RestClientException instead of TimeoutException
src/main/java/hudson/plugins/jira/JiraSite.java Added RestClientException handling and updated method signatures
src/main/java/hudson/plugins/jira/pipeline/*.java Added try-catch blocks to log RestClientException messages to console in SearchIssuesStep, IssueSelectorStep, IssueFieldUpdateStep, and CommentStep
src/main/java/hudson/plugins/jira/JiraIssueUpdateBuilder.java Changed exception handling from TimeoutException to RestClientException
src/main/java/hudson/plugins/jira/JiraEnvironmentVariableBuilder.java Added try-catch to handle RestClientException and log to console
src/main/java/hudson/plugins/jira/JiraCreateIssueNotifier.java Wrapped build result handling in try-catch for RestClientException
src/main/java/hudson/plugins/jira/JiraJobAction.java Added RestClientException to catch block
src/main/java/hudson/plugins/jira/Updater.java Removed RestClientException from method signature and simplified error logging
src/main/java/hudson/plugins/jira/selector/JqlIssueSelector.java Changed exception type from TimeoutException to RestClientException
src/main/java/hudson/plugins/jira/*ParameterDefinition.java Updated method signatures to include RestClientException
src/test/java/hudson/plugins/jira/pipeline/*.java Added comprehensive tests for REST exception handling in pipeline steps
src/test/java/hudson/plugins/jira/*.java Added tests for exception logging and updated existing tests to use RestClientException

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment on lines +146 to +152
doThrow(new RestClientException("[Jira] Jira REST findIsusueIds error. Cause: 401 error", throwable))
.when(issueSelector)
.findIssueIds(build, site, listener);
JiraEnvironmentVariableBuilder builder = spy(new JiraEnvironmentVariableBuilder(issueSelector));
doReturn(site).when(builder).getSiteForProject(project);
assertThat(builder.perform(build, launcher, listener), is(false));
verify(logger).println("[Jira] Jira REST findIsusueIds error. Cause: 401 error");
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

Typo in error message: "findIsusueIds" should be "findIssueIds".

Suggested change
doThrow(new RestClientException("[Jira] Jira REST findIsusueIds error. Cause: 401 error", throwable))
.when(issueSelector)
.findIssueIds(build, site, listener);
JiraEnvironmentVariableBuilder builder = spy(new JiraEnvironmentVariableBuilder(issueSelector));
doReturn(site).when(builder).getSiteForProject(project);
assertThat(builder.perform(build, launcher, listener), is(false));
verify(logger).println("[Jira] Jira REST findIsusueIds error. Cause: 401 error");
doThrow(new RestClientException("[Jira] Jira REST findIssueIds error. Cause: 401 error", throwable))
.when(issueSelector)
.findIssueIds(build, site, listener);
JiraEnvironmentVariableBuilder builder = spy(new JiraEnvironmentVariableBuilder(issueSelector));
doReturn(site).when(builder).getSiteForProject(project);
assertThat(builder.perform(build, launcher, listener), is(false));
verify(logger).println("[Jira] Jira REST findIssueIds error. Cause: 401 error");

Copilot uses AI. Check for mistakes.
@rantoniuk rantoniuk disabled auto-merge November 25, 2025 13:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rantoniuk rantoniuk enabled auto-merge (squash) November 25, 2025 13:17
@rantoniuk rantoniuk merged commit 015261f into master Nov 25, 2025
16 checks passed
@rantoniuk rantoniuk deleted the rantoniuk/pickup-771 branch November 25, 2025 13:45
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.

3 participants