-
Notifications
You must be signed in to change notification settings - Fork 38
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,12 +4,13 @@ | |||||
import java.time.Instant; | ||||||
import java.util.Date; | ||||||
|
||||||
import hudson.model.TaskListener; | ||||||
import org.apache.commons.lang3.StringUtils; | ||||||
import org.apache.log4j.Level; | ||||||
import org.apache.log4j.Logger; | ||||||
|
||||||
import edu.hm.hafner.util.VisibleForTesting; | ||||||
|
||||||
import org.apache.log4j.Level; | ||||||
import org.apache.log4j.Logger; | ||||||
import org.kohsuke.github.GHCheckRunBuilder; | ||||||
import org.kohsuke.github.GitHub; | ||||||
|
||||||
|
@@ -23,23 +24,25 @@ | |||||
* A publisher which publishes GitHub check runs. | ||||||
*/ | ||||||
public class GitHubChecksPublisher extends ChecksPublisher { | ||||||
private static final String GITHUB_URL = "https://api.github.com"; | ||||||
private static final Logger LOGGER = Logger.getLogger(GitHubChecksPublisher.class.getName()); | ||||||
|
||||||
private final GitHubChecksContext context; | ||||||
private final TaskListener listener; | ||||||
|
||||||
/** | ||||||
* {@inheritDoc}. | ||||||
* | ||||||
* @param context | ||||||
* a context which contains SCM properties | ||||||
*/ | ||||||
public GitHubChecksPublisher(final GitHubChecksContext context) { | ||||||
public GitHubChecksPublisher(final GitHubChecksContext context, final TaskListener listener) { | ||||||
super(); | ||||||
|
||||||
this.context = context; | ||||||
this.listener = listener; | ||||||
} | ||||||
|
||||||
private static final Logger LOGGER = Logger.getLogger(GitHubChecksPublisher.class.getName()); | ||||||
private static final String GITHUB_URL = "https://api.github.com"; | ||||||
|
||||||
/** | ||||||
* Publishes a GitHub check run. | ||||||
* | ||||||
|
@@ -54,10 +57,12 @@ public void publish(final ChecksDetails details) { | |||||
credentials); | ||||||
GHCheckRunBuilder builder = createBuilder(gitHub, new GitHubChecksDetails(details)); | ||||||
builder.create(); | ||||||
listener.getLogger().println("GitHub checks have been published."); | ||||||
} | ||||||
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; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
LOGGER.log(Level.WARN, message); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. always log the exception with the throwable arg
Suggested change
|
||||||
listener.getLogger().println(message); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
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?