Skip to content

Commit

Permalink
Merge pull request #57 from jglick/SCMFileSystem-JENKINS-33273-opt
Browse files Browse the repository at this point in the history
SCMFileSystem kill switch
  • Loading branch information
jglick committed Mar 1, 2017
2 parents eddc328 + a979843 commit f42d046
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static class Execution extends AbstractSynchronousNonBlockingStepExecutio
if (defn instanceof CpsScmFlowDefinition) {
// JENKINS-31386: retrofit to work with standalone projects, without doing any trust checks.
standaloneSCM = ((CpsScmFlowDefinition) defn).getScm();
try (SCMFileSystem fs = SCMFileSystem.of(job, standaloneSCM)) {
try (SCMFileSystem fs = SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(job, standaloneSCM)) {
if (fs != null) { // JENKINS-33273
try {
String text = fs.child(step.path).contentAsString();
Expand Down Expand Up @@ -170,8 +170,8 @@ public static class Execution extends AbstractSynchronousNonBlockingStepExecutio
boolean trustCheck = !tip.equals(trusted);
String untrustedFile = null;
String content;
try (SCMFileSystem tipFS = trustCheck ? SCMFileSystem.of(scmSource, head, tip) : null;
SCMFileSystem trustedFS = SCMFileSystem.of(scmSource, head, trusted)) {
try (SCMFileSystem tipFS = trustCheck && !SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? SCMFileSystem.of(scmSource, head, tip) : null;
SCMFileSystem trustedFS = SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(scmSource, head, trusted)) {
if (trustedFS != null && (!trustCheck || tipFS != null)) {
if (trustCheck) {
untrustedFile = tipFS.child(step.path).contentAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
*/
class SCMBinder extends FlowDefinition {

/** Kill switch for JENKINS-33273 in case of problems. */
static /* not final */ boolean USE_HEAVYWEIGHT_CHECKOUT = Boolean.getBoolean(SCMBinder.class.getName() + ".USE_HEAVYWEIGHT_CHECKOUT"); // TODO 2.4+ use SystemProperties

@Override public FlowExecution create(FlowExecutionOwner handle, TaskListener listener, List<? extends Action> actions) throws Exception {
Queue.Executable exec = handle.getExecutable();
if (!(exec instanceof WorkflowRun)) {
Expand All @@ -81,7 +84,7 @@ class SCMBinder extends FlowDefinition {
if (tip != null) {
build.addAction(new SCMRevisionAction(tip));
SCMRevision rev = scmSource.getTrustedRevision(tip, listener);
try (SCMFileSystem fs = SCMFileSystem.of(scmSource, head, rev)) {
try (SCMFileSystem fs = USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(scmSource, head, rev)) {
if (fs != null) { // JENKINS-33273
String script = null;
try {
Expand Down

0 comments on commit f42d046

Please sign in to comment.