Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-42337] Fixed @ timertrigger tokens
  • Loading branch information
v1v committed Feb 27, 2017
1 parent 5889706 commit 581745b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Expand Up @@ -23,15 +23,11 @@ public boolean executeCheck(Item item) {
boolean found = false;
if (item instanceof AbstractProject && ((AbstractProject) item).getTrigger(TimerTrigger.class) != null ) {
String spec = ((AbstractProject) item).getTrigger(TimerTrigger.class).getSpec().toLowerCase();
if (spec.contains("h")) {
String[] myData = spec.split("\n");
for (String line: myData) {
if (!isH(line) && !isComment(line)) {
found = true;
}
String[] myData = spec.split("\n");
for (String line: myData) {
if (!isH(line) && !isComment(line) && !isAt(line)) {
found = true;
}
} else {
found = true;
}
} else {
found = false;
Expand All @@ -54,4 +50,12 @@ private boolean isH (String line) {
found = m.matches();
return found;
}

private boolean isAt (String line) {
boolean found = false;
Pattern p = Pattern.compile("^\\s*@.*");
Matcher m = p.matcher(line);
found = m.matches();
return found;
}
}
Expand Up @@ -35,6 +35,19 @@ public class TimerTriggerCheckerTestCase {
FreeStyleProject project = j.createFreeStyleProject();
assertFalse(checker.executeCheck(project));
}
@Issue("JENKINS-42337")
@Test public void testWithAtTimerTrigger() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
TimerTrigger newTrigger = new TimerTrigger("@daily");
project.addTrigger(newTrigger);
project.save();
assertFalse(checker.executeCheck(project));
project.delete();
newTrigger = new TimerTrigger(TIMER_WITHOUT_H + "\n" +"@daily");
project.addTrigger(newTrigger);
project.save();
assertTrue(checker.executeCheck(project));
}
@Test public void testWithTimerTrigger() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
TimerTrigger newTrigger = new TimerTrigger(TIMER_WITHOUT_H);
Expand Down

0 comments on commit 581745b

Please sign in to comment.