11package com .cloudbees .jenkins ;
22
33import hudson .Extension ;
4+ import hudson .FilePath ;
45import hudson .Launcher ;
56import hudson .Util ;
6- import hudson .model .AbstractBuild ;
77import hudson .model .AbstractProject ;
8- import hudson .model .BuildListener ;
98import hudson .model .Result ;
9+ import hudson .model .Run ;
10+ import hudson .model .TaskListener ;
1011import hudson .tasks .BuildStepDescriptor ;
1112import hudson .tasks .BuildStepMonitor ;
1213import hudson .tasks .Notifier ;
1314import hudson .tasks .Publisher ;
1415import hudson .util .ListBoxModel ;
16+ import jenkins .tasks .SimpleBuildStep ;
17+
1518import org .eclipse .jgit .lib .ObjectId ;
1619import org .jenkinsci .plugins .github .common .ExpandableMessage ;
1720import org .jenkinsci .plugins .github .util .BuildDataHelper ;
4144 *
4245 * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
4346 */
44- public class GitHubCommitNotifier extends Notifier {
47+ public class GitHubCommitNotifier extends Notifier implements SimpleBuildStep {
4548 private static final ExpandableMessage DEFAULT_MESSAGE = new ExpandableMessage ("" );
4649
4750 private ExpandableMessage statusMessage = DEFAULT_MESSAGE ;
@@ -100,12 +103,12 @@ public BuildStepMonitor getRequiredMonitorService() {
100103 }
101104
102105 @ Override
103- public boolean perform (AbstractBuild <?, ?> build ,
106+ public void perform (Run <?, ?> build ,
107+ FilePath ws ,
104108 Launcher launcher ,
105- BuildListener listener ) throws InterruptedException , IOException {
109+ TaskListener listener ) throws InterruptedException , IOException {
106110 try {
107111 updateCommitStatus (build , listener );
108- return true ;
109112 } catch (IOException error ) {
110113 final Result buildResult = getEffectiveResultOnFailure ();
111114 if (buildResult .equals (FAILURE )) {
@@ -118,19 +121,18 @@ public boolean perform(AbstractBuild<?, ?> build,
118121 build .setResult (buildResult );
119122 }
120123 }
121- return true ;
122124 }
123125
124- private void updateCommitStatus (@ Nonnull AbstractBuild <?, ?> build ,
125- @ Nonnull BuildListener listener ) throws InterruptedException , IOException {
126+ private void updateCommitStatus (@ Nonnull Run <?, ?> build ,
127+ @ Nonnull TaskListener listener ) throws InterruptedException , IOException {
126128 final String sha1 = ObjectId .toString (BuildDataHelper .getCommitSHA1 (build ));
127129
128130 StatusResult status = statusFrom (build );
129131 String message = defaultIfEmpty (firstNonNull (statusMessage , DEFAULT_MESSAGE )
130132 .expandAll (build , listener ), status .getMsg ());
131- String contextName = displayNameFor (build .getProject ());
133+ String contextName = displayNameFor (build .getParent ());
132134
133- for (GitHubRepositoryName name : GitHubRepositoryNameContributor .parseAssociatedNames (build .getProject ())) {
135+ for (GitHubRepositoryName name : GitHubRepositoryNameContributor .parseAssociatedNames (build .getParent ())) {
134136 for (GHRepository repository : name .resolve ()) {
135137
136138 listener .getLogger ().println (
@@ -146,7 +148,7 @@ private void updateCommitStatus(@Nonnull AbstractBuild<?, ?> build,
146148 }
147149 }
148150
149- private static StatusResult statusFrom (@ Nonnull AbstractBuild <?, ?> build ) {
151+ private static StatusResult statusFrom (@ Nonnull Run <?, ?> build ) {
150152 Result result = build .getResult ();
151153
152154 // We do not use `build.getDurationString()` because it appends 'and counting' (build is still running)
0 commit comments