Skip to content

Commit

Permalink
[JENKINS-37792] Test when a notification fails
Browse files Browse the repository at this point in the history
  • Loading branch information
rsandell committed Oct 14, 2016
1 parent 061eebc commit b9c1124
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Expand Up @@ -118,6 +118,13 @@ public void withAllLocalChanged() throws Exception {

}

@Test
public void failingNotifications() throws Exception {
expect(Result.FAILURE, "failingNotifications")
.logContains("hello", "Post stage", "farewell", "Error in stage post:", "I AM HERE STILL")
.logNotContains("world").go();
}


//Helper methods and builders, could possibly be moved to something more central for reuse

Expand Down
52 changes: 52 additions & 0 deletions src/test/resources/postStage/failingNotifications.groovy
@@ -0,0 +1,52 @@
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, Inc.
*
* 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.
*/

pipeline {
agent none
stages {
stage("foo") {
steps {
echo "hello"
}
post {
always {
error "farewell"
}
}
}
stage("bar") {
steps {
echo "world"
}
}
}
notifications {
always {
echo "I AM HERE STILL"
}
}
}



0 comments on commit b9c1124

Please sign in to comment.