Skip to content

Commit

Permalink
[JENKINS-46064] Noting future TODOs and some build logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rsandell committed Aug 9, 2017
1 parent abdcb32 commit bd9bf70
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
Expand Up @@ -45,7 +45,7 @@ public class ChangelogConditional extends DeclarativeStageConditional<ChangelogC

@DataBoundConstructor
public ChangelogConditional(String pattern) {
//TODO find a way to validate the regexp in the compile phase
//TODO JENKINS-46065 validate the regexp when #179 is merged
this.pattern = Pattern.compile(pattern);
this.multiLinePattern = Pattern.compile("(?m)(?s)^[^\\r\\n]*?" + pattern + "[^\\r\\n]*?$",
Pattern.MULTILINE | Pattern.DOTALL);
Expand Down
Expand Up @@ -43,7 +43,15 @@ abstract class AbstractChangelogConditionalScript<S extends DeclarativeStageCond
RunWrapper run = this.script.getProperty("currentBuild")
if (run != null) {
List<ChangeLogSet<? extends ChangeLogSet.Entry>> changeSets = run.getChangeSets()
for (int i = 0; i < changeSets.size(); i++) { //TODO can we do .each stuff yet?
if (changeSets.isEmpty()) {
if (run.number <= 1) {
script.echo "Warning, empty changelog. Probably because this is the first build." //TODO JENKINS-46086
} else {
script.echo "Warning, empty changelog. Have you run checkout?"
}
return false
}
for (int i = 0; i < changeSets.size(); i++) { //TODO switch to .any when #174 lands.
def set = changeSets.get(i)
def iterator = set.iterator()
while (iterator.hasNext()) {
Expand Down
Expand Up @@ -39,14 +39,14 @@ class ChangesetConditionalScript extends AbstractChangelogConditionalScript<Chan

@Override
void initializeEval() {
glob = (String)script.evaluate(Utils.prepareForEvalToString(describable.glob))
glob = (String)script.evaluate(Utils.prepareForEvalToString(describable.glob)) //TODO change when #174 lands
glob = glob.replace('\\', '/')
}

@Override
boolean matches(ChangeLogSet.Entry change) {
def iterator = change.affectedPaths.iterator()
while (iterator.hasNext()) {
while (iterator.hasNext()) { //TODO switch to .any when #174 lands
String path = iterator.next();
path = path.replace('\\', '/')
if (DirectoryScanner.match(glob, path, describable.isCaseSensitive())) {
Expand Down
Expand Up @@ -129,7 +129,7 @@ public void paramsInWhenExpression() throws Exception {
public void whenChangeset() throws Exception {
//First time build always skips the changelog
final ExpectationsBuilder builder = expect("when/changelog", "changeset")
.logContains("Hello", "Stage 'Two' skipped due to when conditional")
.logContains("Hello", "Stage 'Two' skipped due to when conditional", "Warning, empty changelog. Probably because this is the first build.")
.logNotContains("JS World");
builder.go();

Expand All @@ -140,15 +140,15 @@ public void whenChangeset() throws Exception {
sampleRepo.git("commit", "--message=files");

builder.logContains("Hello", "JS World")
.logNotContains("Stage 'Two' skipped due to when conditional")
.logNotContains("Stage 'Two' skipped due to when conditional", "Warning, empty changelog.")
.go();
}

@Test
public void whenChangelog() throws Exception {
//First time build always skips the changelog
final ExpectationsBuilder builder = expect("when/changelog", "changelog")
.logContains("Hello", "Stage 'Two' skipped due to when conditional")
.logContains("Hello", "Stage 'Two' skipped due to when conditional", "Warning, empty changelog. Probably because this is the first build.")
.logNotContains("Dull World");
builder.go();

Expand All @@ -159,7 +159,7 @@ public void whenChangelog() throws Exception {
sampleRepo.git("commit", "-m", "Some title that we don't care about\n\nSome explanation\n[DEPENDENCY] some-app#45");

builder.logContains("Hello", "Dull World")
.logNotContains("Stage 'Two' skipped due to when conditional")
.logNotContains("Stage 'Two' skipped due to when conditional", "Warning, empty changelog.")
.go();
}

Expand Down
Expand Up @@ -35,7 +35,9 @@ pipeline {
}
stage("Two") {
when {
changelog '.*^\\[DEPENDENCY\\] .+$' //Perhaps we should use the /../ syntax directly so we don't suffer from ugly escaping?
//Perhaps we should use the /../ syntax directly so we don't suffer from ugly escaping?
//TODO verify the /../ syntax in the #174 parser
changelog '.*^\\[DEPENDENCY\\] .+$'
}
steps {
script {
Expand Down

0 comments on commit bd9bf70

Please sign in to comment.