Skip to content

Commit

Permalink
fixed JENKINS-24286
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrius Ordojan committed Aug 18, 2014
1 parent ea3e467 commit dce9194
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
@@ -1,5 +1,7 @@
package org.jenkinsci.plugins.pretestedintegration;

import hudson.plugins.git.Branch;
import hudson.plugins.git.util.BuildData;
import org.jenkinsci.plugins.pretestedintegration.exceptions.EstablishWorkspaceException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.IntegationFailedExeception;
import org.jenkinsci.plugins.pretestedintegration.exceptions.NextCommitFailureException;
Expand Down Expand Up @@ -160,7 +162,16 @@ public void handlePostBuild( AbstractBuild<?, ?> build, Launcher launcher, Build
Result result = build.getResult();
updateBuildDescription(build, launcher, listener);

BuildData gitBuildData = build.getAction(BuildData.class);
Branch gitDataBranch = gitBuildData.lastBuild.revision.getBranches().iterator().next();
String devBranchName = gitDataBranch.getName();
if (devBranchName.isEmpty() || devBranchName.contains("master")) {
listener.getLogger().println(LOG_PREFIX + "Using the master branch for development is not allowed.");
build.setResult(Result.FAILURE);
}

if (result != null && result.isBetterOrEqualTo(getRequiredResult())) {

listener.getLogger().println(LOG_PREFIX + "Commiting changes");
commit(build, launcher, listener);
listener.getLogger().println(LOG_PREFIX + "Deleting development branch");
Expand Down
Expand Up @@ -40,10 +40,13 @@ public boolean needsToRunAfterFinalized() {
*/
@Override
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) {
listener.getLogger().println("Performing pre-verified post build steps");
PretestedIntegrationAction action = build.getAction(PretestedIntegrationAction.class);
if (action == null)
return true;

listener.getLogger().println("Performing pre-verified post build steps");
Boolean result = false;

try {
result = action.finalise(launcher, listener);
} catch (NullPointerException e) {
Expand Down

0 comments on commit dce9194

Please sign in to comment.