public static ChatMessage fromBuild(Run<?, ?> build, BuildResult buildResult, TaskListener listener) {
ChatMessage msg = new ChatMessage();
StringBuilder content = new StringBuilder();
String projectName = "";
String configuration = "";
if(build.getProject().getRootProject() != build.getProject()) {
projectName = build.getProject().getRootProject().getDisplayName();
configuration = " on " + build.getProject().getDisplayName();
} else {
projectName = build.getProject().getDisplayName();
}
public static List<Entry> parseCommits(Run<?, ?> build) {
final ChangeLogSet<? extends Entry> cs = build.getChangeSet();
if(cs == null || cs.isEmptySet())
return null;
List<Entry> commits = new ArrayList();
for (final Entry entry : cs) {
// reverse order in order to have recent commits first
commits.add(0, entry);
}
return commits;
}
try { sshagent([config.gitCredentials]) {
withMaven(maven: 'Maven', mavenLocalRepo: '.repository', mavenSettingsConfig: 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1450194231885') { sh "mvn versions:set -DnewVersion=${version}" sh "mvn clean install" } }
} catch (err) {
mail body: "Please go to ${BUILD_URL} and verify the build." , from: config.email, replyTo: config.email, subject: "Build failed in Jenkins: ${JOB_NAME} ${version}", to: config.recipients
throw err } finally { // Post build items here -- build will have already passed or failed by now? flowdockNotifier(flowToken: 'myflowdocktoken', notificationTags: "jenkins, ${JOB_NAME}", chatNotification:true, notifyFailure: true)
}
public static class Execution extends AbstractSynchronousStepExecution<Void> {
@StepContextParameter private transient Launcher launcher;
@StepContextParameter private transient FilePath workspace;
@StepContextParameter private transient TaskListener listener;
@StepContextParameter private transient Run<?, ?> run;
@StepContextParameter private transient EnvVars env;
@Inject(optional=true) private transient FlowdockNotifierStep step;
@Override
protected Void run() throws Exception {
listener.getLogger().println("Running flowdock notifier.");
FlowdockNotifier notifier = new FlowdockNotifier(step.flowToken,
step.notificationTags,
convertToString(step.chatNotification),
convertToString(step.notifySuccess),
convertToString(step.notifyFailure),
convertToString(step.notifyFixed),
convertToString(step.notifyUnstable),
convertToString(step.notifyAborted),
convertToString(step.notifyNotBuilt));
notifier.perform(run, workspace, launcher, listener);
return null;
}
private static final long serialVersionUID = 1L;
private static String convertToString(Boolean bool) {
return bool != null ? bool.toString() : null;
}
}
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/kI0BtRoE7kM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2igFVJW-gMuaUvrFW%2Btf-874Cx3CaRY1yD1FzJRYemLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/kI0BtRoE7kM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0ZKnJvuQwva_Q6tbBnPWEwh-2jmsPC4z-oTT5P_TmgZw%40mail.gmail.com.