-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail fast when attempting to run PCT against a release with a missing…
… or nondeterministic tag (#499)
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/org/jenkins/tools/test/hook/TagValidationHook.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,27 @@ | ||
package org.jenkins.tools.test.hook; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import org.apache.maven.model.Model; | ||
import org.jenkins.tools.test.exception.PluginSourcesUnavailableException; | ||
import org.jenkins.tools.test.model.hook.BeforeCheckoutContext; | ||
import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeCheckout; | ||
import org.kohsuke.MetaInfServices; | ||
|
||
@MetaInfServices(PluginCompatTesterHookBeforeCheckout.class) | ||
public class TagValidationHook extends PluginCompatTesterHookBeforeCheckout { | ||
|
||
@Override | ||
public boolean check(@NonNull BeforeCheckoutContext context) { | ||
return context.getConfig().getLocalCheckoutDir() == null; | ||
} | ||
|
||
@Override | ||
public void action(@NonNull BeforeCheckoutContext context) | ||
throws PluginSourcesUnavailableException { | ||
Model model = context.getModel(); | ||
if (model.getScm().getTag() == null || model.getScm().getTag().equals("HEAD")) { | ||
throw new PluginSourcesUnavailableException( | ||
"Failed to check out plugin sources for " + model.getVersion()); | ||
} | ||
} | ||
} |