Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean workspace before building incrementals #141

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/groovy/BuildPluginStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class BuildPluginStepTests extends BasePipelineTest {
assertTrue(helper.callStack.findAll { call ->
call.methodName == 'error'
}.any { call ->
callArgsToString(call).contains('Configuration filed "jdk" must be specified: [platform:linux]')
callArgsToString(call).contains('Configuration field "jdk" must be specified: [platform:linux]')
})
assertJobStatusFailure()
}
Expand Down
13 changes: 12 additions & 1 deletion vars/buildPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def call(Map params = [:]) {
isMaven = fileExists('pom.xml')
incrementals = fileExists('.mvn/extensions.xml') &&
readFile('.mvn/extensions.xml').contains('git-changelist-maven-extension')
if (incrementals) { // Incrementals needs 'git status -s' to be empty at start of job
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not just do this unconditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We certainly could, but I wanted to keep the impact of the change to only those specific cases where I know it is an issue. I'm willing to change the pull request to do it in all cases if that will help with its approval.

if (isUnix()) {
sh(script: 'git clean -xffd || true',
label:'Clean for incrementals',
returnStatus: true) // Ignore failure if CLI git is not available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the || true not sufice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should, but I was practicing an "abundance of caution" in hopes that a peripheral cleanup operation would have even less chance of inadvertently breaking a build.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then returnStatus: true should suffice (both both platforms)?

Copy link
Contributor Author

@MarkEWaite MarkEWaite May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should. Same "abundance of caution" logic. If ignoring the return value inside the script somehow did not work, also take the active measure of ignoring the return value from the step. Both sh and bat step documentation say:

Normally, a script which exits with a nonzero status code will cause the step to fail with an exception. If this option is checked, the return value of the step will instead be the status code.

Copy link
Contributor Author

@MarkEWaite MarkEWaite May 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed to hide the output from git clean and ignore the return code in c05194b . Let me know if other changes are needed (after the fix to change the Windows null device to the correct name nul instead of the incorrect name null)

} else {
bat(script: 'git clean -xffd || echo "git clean failure intentionally ignored in incrementals setup"',
label:'Clean for incrementals',
returnStatus: true) // Ignore failure if CLI git is not available
}
}
}

String changelistF
Expand Down Expand Up @@ -225,7 +236,7 @@ List<Map<String, String>> getConfigurations(Map params) {
error("Configuration field \"platform\" must be specified: $c")
}
if (!c.jdk) {
error("Configuration filed \"jdk\" must be specified: $c")
error("Configuration field \"jdk\" must be specified: $c")
}
}

Expand Down