Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #46 from oleg-nenashev/JENKINS-23641
[JENKINS-23641,JENKINS-25312] - Handle possible nulls if Git checkout fails
- Loading branch information
Showing
4 changed files
with
143 additions
and
6 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
7 changes: 7 additions & 0 deletions
7
src/main/resources/com/cloudbees/jenkins/GitHubCommitNotifier/config.jelly
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,7 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<f:advanced> | ||
<f:entry title="${%Result on failure}" field="resultOnFailure"> | ||
<f:select/> | ||
</f:entry> | ||
</f:advanced> | ||
</j:jelly> |
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
65 changes: 65 additions & 0 deletions
65
src/test/java/com/cloudbees/jenkins/GitHubCommitNotifierTest.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,65 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package com.cloudbees.jenkins; | ||
|
||
import hudson.model.Build; | ||
import hudson.model.FreeStyleProject; | ||
import hudson.model.Result; | ||
import hudson.plugins.git.GitSCM; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Bug; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
/** | ||
* Tests for {@link GitHubCommitNotifier}. | ||
* @author Oleg Nenashev <o.v.nenashev@gmail.com> | ||
*/ | ||
public class GitHubCommitNotifierTest extends HudsonTestCase { | ||
|
||
// @Rule | ||
// public JenkinsRule r = new JenkinsRule(); | ||
|
||
|
||
@Test | ||
@Bug(23641) | ||
public void testNoBuildData() throws Exception, InterruptedException { | ||
FreeStyleProject prj = createFreeStyleProject("23641_noBuildData"); | ||
prj.getPublishersList().add(new GitHubCommitNotifier()); | ||
Build b = prj.scheduleBuild2(0).get(); | ||
assertBuildStatus(Result.FAILURE, b); | ||
assertLogContains(Messages.GitHubCommitNotifier_NoBuildDataError(), b); | ||
} | ||
|
||
@Test | ||
@Bug(23641) | ||
public void testNoBuildRevision() throws Exception, InterruptedException { | ||
FreeStyleProject prj = createFreeStyleProject(); | ||
prj.setScm(new GitSCM("http://non.existent.git.repo.nowhere/repo.git")); | ||
prj.getPublishersList().add(new GitHubCommitNotifier()); | ||
Build b = prj.scheduleBuild2(0).get(); | ||
assertBuildStatus(Result.FAILURE, b); | ||
assertLogContains(Messages.GitHubCommitNotifier_NoLastRevisionError(), b); | ||
} | ||
|
||
@Bug(25312) | ||
public @Test void testMarkUnstableOnCommitNotifierFailure() throws Exception, InterruptedException { | ||
FreeStyleProject prj = createFreeStyleProject(); | ||
prj.getPublishersList().add(new GitHubCommitNotifier(Result.UNSTABLE.toString())); | ||
Build b = prj.scheduleBuild2(0).get(); | ||
assertBuildStatus(Result.UNSTABLE, b); | ||
} | ||
|
||
@Bug(25312) | ||
public @Test void testMarkSuccessOnCommitNotifierFailure() throws Exception, InterruptedException { | ||
FreeStyleProject prj = createFreeStyleProject(); | ||
prj.getPublishersList().add(new GitHubCommitNotifier(Result.SUCCESS.toString())); | ||
Build b = prj.scheduleBuild2(0).get(); | ||
assertBuildStatus(Result.SUCCESS, b); | ||
} | ||
} |