Skip to content
Permalink
Browse files

Fix JENKINS-4100 and JENKINS-11895

- Added BUILD_ID token and JOB_DESCRIPTION token
  • Loading branch information...
slide committed Mar 8, 2012
1 parent 09296a6 commit b19a26597d190c934ce96572c689124cb451cd34
@@ -27,6 +27,7 @@
import hudson.plugins.emailext.plugins.ContentBuilder;
import hudson.plugins.emailext.plugins.EmailContent;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.content.BuildIdContent;
import hudson.plugins.emailext.plugins.content.BuildLogContent;
import hudson.plugins.emailext.plugins.content.BuildLogRegexContent;
import hudson.plugins.emailext.plugins.content.BuildLogExcerptContent;
@@ -42,6 +43,7 @@
import hudson.plugins.emailext.plugins.content.HudsonURLContent;
import hudson.plugins.emailext.plugins.content.JellyScriptContent;
import hudson.plugins.emailext.plugins.content.JenkinsURLContent;
import hudson.plugins.emailext.plugins.content.JobDescriptionContent;
import hudson.plugins.emailext.plugins.content.ProjectNameContent;
import hudson.plugins.emailext.plugins.content.ProjectURLContent;
import hudson.plugins.emailext.plugins.content.SVNRevisionContent;
@@ -73,6 +75,7 @@
@Override
public void start() throws Exception {
//We are adding different Content plugins to the list of content types.
addEmailContentPlugin(new BuildIdContent());
addEmailContentPlugin(new BuildLogContent());
addEmailContentPlugin(new BuildLogRegexContent());
addEmailContentPlugin(new BuildLogExcerptContent());
@@ -93,6 +96,7 @@ public void start() throws Exception {
addEmailContentPlugin(new JellyScriptContent());
addEmailContentPlugin(new WorkspaceFileContent());
addEmailContentPlugin(new TestCountsContent());
addEmailContentPlugin(new JobDescriptionContent());
try {
addEmailContentPlugin(new ScriptContent());
} catch (NoClassDefFoundError jvm15Error) {
@@ -0,0 +1,37 @@
package hudson.plugins.emailext.plugins.content;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.plugins.emailext.EmailType;
import hudson.plugins.emailext.ExtendedEmailPublisher;
import hudson.plugins.emailext.plugins.EmailContent;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class BuildIdContent implements EmailContent {

private static final String TOKEN = "BUILD_ID";

public String getToken() {
return TOKEN;
}

public List<String> getArguments() {
return Collections.emptyList();
}

public String getHelpText() {
return "Displays the build ID of the current build.";
}

public <P extends AbstractProject<P, B>, B extends AbstractBuild<P, B>> String getContent(AbstractBuild<P, B> build, ExtendedEmailPublisher publisher,
EmailType emailType, Map<String, ?> args) {
return build.getId();
}

public boolean hasNestedContent() {
return false;
}
}
@@ -0,0 +1,37 @@
package hudson.plugins.emailext.plugins.content;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.plugins.emailext.EmailType;
import hudson.plugins.emailext.ExtendedEmailPublisher;
import hudson.plugins.emailext.plugins.EmailContent;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class JobDescriptionContent implements EmailContent {

private static final String TOKEN = "JOB_DESCRIPTION";

public String getToken() {
return TOKEN;
}

public List<String> getArguments() {
return Collections.emptyList();
}

public String getHelpText() {
return "Displays the description of the job.";
}

public <P extends AbstractProject<P, B>, B extends AbstractBuild<P, B>> String getContent(AbstractBuild<P, B> build, ExtendedEmailPublisher publisher,
EmailType emailType, Map<String, ?> args) {
return build.getParent().getDescription();
}

public boolean hasNestedContent() {
return false;
}
}

0 comments on commit b19a265

Please sign in to comment.
You can’t perform that action at this time.