Skip to content

Commit

Permalink
Merge pull request #26 from andrewgoktepe/force-sync
Browse files Browse the repository at this point in the history
Add Force Sync option to repo plugin
  • Loading branch information
rsandell committed Sep 25, 2015
2 parents 295e079 + b4a140b commit b9eed66
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424</version><!-- which version of Hudson is this plugin built against? -->
<version>1.554.3</version><!-- which version of Hudson is this plugin built against? -->
</parent>

<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/hudson/plugins/repo/RepoScm.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.Exported;
Expand Down Expand Up @@ -90,6 +91,7 @@ public class RepoScm extends SCM implements Serializable {
private final boolean currentBranch;
private final boolean resetFirst;
private final boolean quiet;
private boolean forceSync;
private final boolean trace;
private final boolean showAllChanges;

Expand Down Expand Up @@ -240,6 +242,13 @@ public boolean isCurrentBranch() {
public boolean isQuiet() {
return quiet;
}
/**
* Returns the value of forceSync.
*/
@Exported
public boolean isForceSync() {
return forceSync;
}
/**
* Returns the value of trace.
*/
Expand Down Expand Up @@ -328,6 +337,17 @@ public RepoScm(final String manifestRepositoryUrl,
this.repoUrl = Util.fixEmptyAndTrim(repoUrl);
}

/**
* Enables --force-sync option on repo sync command.
* @param forceSync
* If this value is true, add the "--force-sync" option when
* executing "repo sync".
*/
@DataBoundSetter
public void setForceSync(final boolean forceSync) {
this.forceSync = forceSync;
}

@Override
public SCMRevisionState calcRevisionsFromBuild(
final AbstractBuild<?, ?> build, final Launcher launcher,
Expand Down Expand Up @@ -462,6 +482,9 @@ private int doSync(final Launcher launcher, final FilePath workspace,
if (isQuiet()) {
commands.add("-q");
}
if (isForceSync()) {
commands.add("--force-sync");
}
if (jobs > 0) {
commands.add("--jobs=" + jobs);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/hudson/plugins/repo/RepoScm/config.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<f:checkbox name="repo.quiet" checked="${h.defaultToTrue(scm.quiet)}" />
</f:entry>

<f:entry title="Force Sync" help="/plugin/repo/help-forceSync.html">
<f:checkbox name="repo.forceSync" checked="${scm.forceSync}" />
</f:entry>

<f:entry title="Trace" help="/plugin/repo/help-trace.html">
<f:checkbox name="repo.trace" checked="${scm.trace}" />
</f:entry>
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/help-forceSync.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
<p>
Continue sync even if a project fails to sync
This is passed to repo as <code>repo sync <i>--force-sync</i></code>.
</p>
</div>

0 comments on commit b9eed66

Please sign in to comment.