Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-33273 kill switch.
  • Loading branch information
jglick committed Feb 28, 2017
1 parent eddc328 commit a979843
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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
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 a979843

Please sign in to comment.