@@ -132,6 +132,7 @@ public class RepoScm extends SCM implements Serializable {
132132 @ CheckForNull private EnvVars extraEnvVars ;
133133 @ CheckForNull private boolean noCloneBundle ;
134134 @ CheckForNull private boolean worktree ;
135+ @ CheckForNull private boolean noSync ;
135136
136137 /**
137138 * Returns the manifest repository URL.
@@ -387,6 +388,13 @@ public Map<String, String> getExtraEnvVars() {
387388 return extraEnvVars ;
388389 }
389390
391+ /**
392+ * Returns the value of noSync.
393+ */
394+ public boolean isNoSync () {
395+ return noSync ;
396+ }
397+
390398 /**
391399 * The constructor takes in user parameters and sets them. Each job using
392400 * the RepoSCM will call this constructor.
@@ -491,6 +499,7 @@ public RepoScm(final String manifestRepositoryUrl) {
491499 ignoreProjects = Collections .<String >emptySet ();
492500 noCloneBundle = false ;
493501 worktree = false ;
502+ noSync = false ;
494503 }
495504
496505 /**
@@ -738,6 +747,17 @@ public void setForceSync(final boolean forceSync) {
738747 this .forceSync = forceSync ;
739748 }
740749
750+ /**
751+ * disables -sync option on repo command.
752+ * @param noSync
753+ * If this value is true, do not add the "-sync" option when
754+ * executing "repo ".
755+ */
756+ @ DataBoundSetter
757+ public void setNoSync (final boolean noSync ) {
758+ this .noSync = noSync ;
759+ }
760+
741761 /**
742762 * Set noTags.
743763 *
@@ -1057,7 +1077,7 @@ private boolean checkoutCode(final Launcher launcher,
10571077
10581078 commands .add (getDescriptor ().getExecutable ());
10591079 if (trace ) {
1060- commands .add ("--trace" );
1080+ commands .add ("--trace" );
10611081 }
10621082 commands .add ("init" );
10631083 commands .add ("-u" );
@@ -1112,6 +1132,10 @@ private boolean checkoutCode(final Launcher launcher,
11121132 if (returnCode != 0 ) {
11131133 return false ;
11141134 }
1135+ if (isNoSync ()) {
1136+ debug .log (Level .FINEST , "Repo init completed successfully, not running repo sync" );
1137+ return true ;
1138+ }
11151139
11161140 if (localManifest != null ) {
11171141 if (!lmdir .exists ()) {
@@ -1140,10 +1164,10 @@ private boolean checkoutCode(final Launcher launcher,
11401164 commands .add ("-c" );
11411165 commands .add ("git reset --hard" );
11421166 launcher .launch ().stdout (logger ).pwd (workspace ).cmds (commands )
1143- .envs (env ).join ();
1167+ .envs (env ).join ();
11441168 returnCode = doSync (launcher , workspace , logger , env );
11451169 if (returnCode != 0 ) {
1146- return false ;
1170+ return false ;
11471171 }
11481172 }
11491173 return true ;
0 commit comments