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

Print console log #17

Merged
merged 4 commits into from
Aug 4, 2020
Merged

Print console log #17

merged 4 commits into from
Aug 4, 2020

Conversation

XiongKezhi
Copy link
Contributor

Use TaskListener to print console log

@XiongKezhi XiongKezhi added the enhancement New feature or request label Aug 4, 2020
@XiongKezhi XiongKezhi requested a review from timja August 4, 2020 07:41
@XiongKezhi XiongKezhi requested a review from a team as a code owner August 4, 2020 07:41
@XiongKezhi XiongKezhi self-assigned this Aug 4, 2020
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.

slight rewording

}
catch (IllegalStateException | IOException e) {
//TODO: log to the build console
LOGGER.log(Level.WARN, "Could not publish GitHub check run", e);
Copy link
Member

Choose a reason for hiding this comment

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

still worth logging this to the system?

Job<?, ?> job = context.getJob();
Optional<GitHubSCMSource> source = scmFacade.findGitHubSCMSource(job);
if (!source.isPresent()) {
listener.getLogger().println("Failed creating GitHub checks publisher: no GitHub SCM source found.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
listener.getLogger().println("Failed creating GitHub checks publisher: no GitHub SCM source found.");
listener.getLogger().println("Skipped publishing GitHub checks: no GitHub SCM found.");

return Optional.empty();
}

String credentialsId = source.get().getCredentialsId();
if (credentialsId == null
|| !scmFacade.findGitHubAppCredentials(job, credentialsId).isPresent()) {
listener.getLogger().println("Failed creating GitHub checks publisher: no GitHub APP credentials found.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
listener.getLogger().println("Failed creating GitHub checks publisher: no GitHub APP credentials found.");
listener.getLogger().println("Skipped publishing GitHub checks: no GitHub APP credentials found, see https://github.com/jenkinsci/github-branch-source-plugin/blob/master/docs/github-app.adoc");

return Optional.empty();
}

return Optional.of(new GitHubChecksPublisher(context));
listener.getLogger().println("Using GitHub checks publisher.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
listener.getLogger().println("Using GitHub checks publisher.");
listener.getLogger().println("Publishing GitHub checks.");

@XiongKezhi
Copy link
Contributor Author

irrelevant CI failure

//TODO: log to the build console
LOGGER.log(Level.WARN, "Could not publish GitHub check run", e);
String message = "Failed Publishing GitHub checks: " + e;
LOGGER.log(Level.WARN, message);
Copy link
Member

Choose a reason for hiding this comment

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

always log the exception with the throwable arg

Suggested change
LOGGER.log(Level.WARN, message);
LOGGER.log(Level.WARN, message, e);

LOGGER.log(Level.WARN, "Could not publish GitHub check run", e);
String message = "Failed Publishing GitHub checks: " + e;
LOGGER.log(Level.WARN, message);
listener.getLogger().println(message);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
listener.getLogger().println(message);
listener.getLogger().println(message + e);

}
catch (IllegalStateException | IOException e) {
//TODO: log to the build console
LOGGER.log(Level.WARN, "Could not publish GitHub check run", e);
String message = "Failed Publishing GitHub checks: " + e;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
String message = "Failed Publishing GitHub checks: " + e;
String message = "Failed Publishing GitHub checks: ";

@XiongKezhi XiongKezhi requested a review from timja August 4, 2020 09:23
@XiongKezhi XiongKezhi merged commit bdf3244 into master Aug 4, 2020
@XiongKezhi XiongKezhi deleted the add-console-log branch August 4, 2020 09:34
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.

2 participants