Skip to content

Commit

Permalink
[FIXED JENKINS-24341] - Check if the project can be disabled before …
Browse files Browse the repository at this point in the history
…the disabling

The change call the AbstractProject::supportsMakeDisabled() before calling AbstractProject::makeDisabled()

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information
oleg-nenashev committed Aug 20, 2014
1 parent 91b92a5 commit 9ea9dd8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/java/hudson/scm/SubversionSCM.java
Expand Up @@ -889,7 +889,7 @@ private List<External> checkout(Run build, FilePath workspace, TaskListener list
// see http://www.nabble.com/Should-Hudson-have-an-option-for-a-content-fingerprint--td24022683.html

listener.getLogger().println("One or more repository locations do not exist anymore for " + build.getParent().getName() + ", project will be disabled.");
((AbstractBuild) build).getProject().makeDisabled(true);
disableProject(((AbstractBuild) build).getProject(), listener);
return null;
}
}
Expand Down Expand Up @@ -1353,7 +1353,7 @@ else if (project.getLastBuild()!=null) {
// Disable this project, see HUDSON-763
listener.getLogger().println(
Messages.SubversionSCM_pollChanges_locationsNoLongerExist(project));
((AbstractProject) project).makeDisabled(true);
disableProject((AbstractProject) project, listener);
return NO_CHANGES;
}

Expand Down Expand Up @@ -2538,6 +2538,22 @@ public boolean repositoryLocationsNoLongerExist(Run<?,?> build, TaskListener lis
}
return false;
}

/**
* Disables the project if it is possible and prints messages to the log.
* @param project Project to be disabled
* @param listener Logger
* @throws IOException Cannot disable the project
*/
private void disableProject(@NonNull AbstractProject project, @NonNull TaskListener listener)
throws IOException {
if (project.supportsMakeDisabled()) {
project.makeDisabled(true);
listener.getLogger().println(Messages.SubversionSCM_disableProject_disabled());
} else {
listener.getLogger().println(Messages.SubversionSCM_disableProject_unsupported());
}
}

static final Pattern URL_PATTERN = Pattern.compile("(https?|svn(\\+[a-z0-9]+)?|file)://.+");

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/hudson/scm/subversion/Messages.properties
Expand Up @@ -68,6 +68,10 @@ SubversionSCM.pollChanges.ignoredRevision.onlydirprops=\
SubversionSCM.pollChanges.exception=\
Failed to check repository revision for {0}
SubversionSCM.perJobCredentialsMigration=Migrate any legacy Subversion per-job credential stores
SubversionSCM.disableProject.disabled=\
The project has been disabled
SubversionSCM.disableProject.unsupported=\
The project does not support the disabling

SubversionUpdateEventHandler.FetchExternal=\
Fetching ''{0}'' at {1} into ''{2}''
Expand Down

0 comments on commit 9ea9dd8

Please sign in to comment.