Skip to content
Permalink
Browse files

[JENKINS-42337] Fixed @ timertrigger tokens

  • Loading branch information...
v1v committed Feb 27, 2017
1 parent 5889706 commit 581745be76f36bbf78ec31edae99ee8b42788a6b
@@ -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;
@@ -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;
}
}
@@ -35,6 +35,19 @@
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);

0 comments on commit 581745b

Please sign in to comment.
You can’t perform that action at this time.