This repository was archived by the owner on Feb 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jenkinsci/make-pipeline
pipeline
- Loading branch information
Showing
22 changed files
with
553 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sun Dec 28 22:38:17 JST 2014 | ||
#Sun May 15 00:42:41 JST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/org/jenkinsci/plugins/typetalk/delegate/BuildWrapperDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.jenkinsci.plugins.typetalk.delegate; | ||
|
||
import hudson.model.Result; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.jenkinsci.plugins.typetalk.api.Typetalk; | ||
import org.jenkinsci.plugins.typetalk.support.Emoji; | ||
import org.jenkinsci.plugins.typetalk.support.TypetalkMessage; | ||
|
||
import java.io.IOException; | ||
|
||
public class BuildWrapperDelegate { | ||
|
||
private final String name; | ||
|
||
private final Long topicId; | ||
|
||
private final TaskListener listener; | ||
|
||
private final Run run; | ||
|
||
public BuildWrapperDelegate(String name, Long topicId, TaskListener listener, Run run) { | ||
this.name = name; | ||
this.topicId = topicId; | ||
this.listener = listener; | ||
this.run = run; | ||
} | ||
|
||
public void notifyStart(boolean notifyStart, String notifyStartMessage) throws IOException, InterruptedException { | ||
if (notifyStart) { | ||
listener.getLogger().println("Notifying build start to Typetalk..."); | ||
|
||
String message; | ||
if (StringUtils.isBlank(notifyStartMessage)) { | ||
TypetalkMessage typetalkMessage = new TypetalkMessage(Emoji.LOUDSPEAKER, "Build start"); | ||
message = typetalkMessage.buildMessageWithBuild(run); | ||
} else { | ||
message = run.getEnvironment(listener).expand(notifyStartMessage); | ||
} | ||
|
||
Typetalk.createFromName(name).postMessage(topicId, message); | ||
} | ||
} | ||
|
||
public void notifyEnd(boolean notifyEnd, String notifyEndMessage) throws IOException, InterruptedException { | ||
if (notifyEnd && isSuccessBuild(run)) { | ||
listener.getLogger().println("Notifying build end to Typetalk..."); | ||
|
||
String message; | ||
if (StringUtils.isBlank(notifyEndMessage)) { | ||
TypetalkMessage typetalkMessage = new TypetalkMessage(Emoji.MEGA, "Build end"); | ||
message = typetalkMessage.buildMessageWithBuild(run); | ||
} else { | ||
message = run.getEnvironment(listener).expand(notifyEndMessage); | ||
} | ||
|
||
Typetalk.createFromName(name).postMessage(topicId, message); | ||
} | ||
} | ||
|
||
private boolean isSuccessBuild(Run run) { | ||
// When there is nothing failure (equals success), getResult hasn't been set yet. | ||
return run.getResult() == null || run.getResult().equals(Result.SUCCESS); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/org/jenkinsci/plugins/typetalk/delegate/NotifyDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.jenkinsci.plugins.typetalk.delegate; | ||
|
||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import org.jenkinsci.plugins.typetalk.api.Typetalk; | ||
import org.jenkinsci.plugins.typetalk.support.ResultSupport; | ||
import org.jenkinsci.plugins.typetalk.support.TypetalkMessage; | ||
|
||
import java.io.IOException; | ||
|
||
public class NotifyDelegate { | ||
|
||
private final String name; | ||
|
||
private final Long topicId; | ||
|
||
private final TaskListener listener; | ||
|
||
private final Run run; | ||
|
||
public NotifyDelegate(String name, Long topicId, TaskListener listener, Run run) { | ||
this.name = name; | ||
this.topicId = topicId; | ||
this.listener = listener; | ||
this.run = run; | ||
} | ||
|
||
public void notifyResult() throws IOException { | ||
ResultSupport resultSupport = new ResultSupport(); | ||
if (resultSupport.isSuccessFromSuccess(run)) { | ||
return; | ||
} | ||
|
||
listener.getLogger().println("Notifying build result to Typetalk..."); | ||
|
||
TypetalkMessage typetalkMessage = resultSupport.convertBuildToMessage(run); | ||
String message = typetalkMessage.buildMessageWithBuild(run); | ||
|
||
Typetalk.createFromName(name).postMessage(topicId, message); | ||
} | ||
|
||
} |
Oops, something went wrong.