[
https://issues.jenkins-ci.org/browse/JENKINS-7859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=162860#comment-162860
]
Slide-O-Mix commented on JENKINS-7859:
--
Please clone the git repo, make the change and issue a pull request.
Email-ext trigger for the transition from success to failure
Key: JENKINS-7859
URL: https://issues.jenkins-ci.org/browse/JENKINS-7859
Project: Jenkins
Issue Type: New Feature
Components: email-ext
Affects Versions: current
Reporter: branso
Continuation from JENKINS-7858. Wasn't able to add a comment for some reason.
Email-ext currently does not have a trigger for when a build goes from
success to failure. The failure triggers on every failed build however the
patch the I'm suggesting will only trigger on the transition.
To add this feature change/add the following files
* hudson/plugins/emailext/EmailExtensionPlugin.java add the lines indicated
{code:java}
/*
* The MIT License
*
* Copyright (c) 2010, kyle.swee...@valtech.com, Stellar Science Ltd Co, K.
R. Walker
*
* Permission is hereby granted, free of charge, to any person obtaining a
copy
* of this software and associated documentation files (the Software), to
deal
* in the Software without restriction, including without limitation the
rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.plugins.emailext;
import hudson.Plugin;
import hudson.plugins.emailext.plugins.ContentBuilder;
import hudson.plugins.emailext.plugins.EmailContent;
import hudson.plugins.emailext.plugins.EmailTriggerDescriptor;
import hudson.plugins.emailext.plugins.content.*;
import hudson.plugins.emailext.plugins.trigger.*;
import hudson.plugins.emailext.plugins.trigger.FirstFailureTrigger; //add
line
/**
* Entry point of a plugin.
*
* p
* There must be one {@link Plugin} class in each plugin.
* See javadoc of {@link Plugin} for more about what can be done on this
class.
*
* @author kyle.swee...@valtech.com
*/
public class EmailExtensionPlugin extends Plugin {
@Override
public void start() throws Exception {
//We are adding different Content plugins to the list of
content types.
addEmailContentPlugin(new BuildLogContent());
addEmailContentPlugin(new BuildLogRegexContent());
addEmailContentPlugin(new BuildNumberContent());
addEmailContentPlugin(new BuildStatusContent());
addEmailContentPlugin(new BuildURLContent());
addEmailContentPlugin(new ChangesSinceLastBuildContent());
addEmailContentPlugin(new
ChangesSinceLastSuccessfulBuildContent());
addEmailContentPlugin(new
ChangesSinceLastUnstableBuildContent());
addEmailContentPlugin(new EnvContent());
addEmailContentPlugin(new FailedTestsContent());
addEmailContentPlugin(new HudsonURLContent());
addEmailContentPlugin(new ProjectNameContent());
addEmailContentPlugin(new ProjectURLContent());
addEmailContentPlugin(new SVNRevisionContent());
addEmailContentPlugin(new CauseContent());
addEmailContentPlugin(new JellyScriptContent());
addEmailTriggerPlugin(PreBuildTrigger.DESCRIPTOR);
addEmailTriggerPlugin(FailureTrigger.DESCRIPTOR);
addEmailTriggerPlugin(StillFailingTrigger.DESCRIPTOR);
addEmailTriggerPlugin(UnstableTrigger.DESCRIPTOR);
addEmailTriggerPlugin(StillUnstableTrigger.DESCRIPTOR);
addEmailTriggerPlugin(SuccessTrigger.DESCRIPTOR);
addEmailTriggerPlugin(FixedTrigger.DESCRIPTOR);
addEmailTriggerPlugin(FirstFailureTrigger.DESCRIPTOR);//add
line
}
private void addEmailContentPlugin(EmailContent content) {
try {
ContentBuilder.addEmailContentType(content);