Skip to content

Commit

Permalink
Fail fast when attempting to run PCT against a release with a missing…
Browse files Browse the repository at this point in the history
… or nondeterministic tag (#499)
  • Loading branch information
basil committed Mar 24, 2023
1 parent b779758 commit 5a54bfd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/org/jenkins/tools/test/hook/TagValidationHook.java
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());
}
}
}

0 comments on commit 5a54bfd

Please sign in to comment.