Skip to content

Commit

Permalink
Merge pull request #47 from Brantone/master
Browse files Browse the repository at this point in the history
Support 'Ownership' plugin. closes #43
  • Loading branch information
drekbour committed Jun 21, 2015
2 parents 97610a0 + 66c1dc6 commit 4fd1585
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ public class TemplateImplementationProperty extends JobProperty<AbstractProject<
private final boolean syncDisabled;
private final boolean syncSecurity;
private final boolean syncScm;
private final boolean syncOwnership;

@DataBoundConstructor
public TemplateImplementationProperty(String templateJobName, boolean syncMatrixAxis, boolean syncDescription, boolean syncBuildTriggers, boolean syncDisabled, boolean syncSecurity, boolean syncScm) {
public TemplateImplementationProperty(String templateJobName, boolean syncMatrixAxis, boolean syncDescription, boolean syncBuildTriggers, boolean syncDisabled, boolean syncSecurity, boolean syncScm, boolean syncOwnership) {
this.templateJobName = templateJobName;
this.syncMatrixAxis = syncMatrixAxis;
this.syncDescription = syncDescription;
this.syncBuildTriggers = syncBuildTriggers;
this.syncDisabled = syncDisabled;
this.syncSecurity = syncSecurity;
this.syncScm = syncScm;
this.syncOwnership = syncOwnership;
}

@Exported
Expand Down Expand Up @@ -72,6 +74,10 @@ public boolean getSyncScm() {
return syncScm;
}

public boolean getSyncOwnership() {
return syncOwnership;
}

public AbstractProject findTemplate() {
return ProjectUtils.findProject(getTemplateJobName());
}
Expand All @@ -90,8 +96,9 @@ public JobProperty<?> newInstance(StaplerRequest request, JSONObject formData) t
boolean syncDisabled = useTemplate.getBoolean("syncDisabled");
boolean syncSecurity = useTemplate.getBoolean("syncSecurity");
boolean syncScm = useTemplate.getBoolean("syncScm");
boolean syncOwnership = useTemplate.getBoolean("syncOwnership");

return new TemplateImplementationProperty(templateJobName, syncMatrixAxis, syncDescription, syncBuildTriggers, syncDisabled, syncSecurity, syncScm);
return new TemplateImplementationProperty(templateJobName, syncMatrixAxis, syncDescription, syncBuildTriggers, syncDisabled, syncSecurity, syncScm, syncOwnership);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static void handleTemplateCopied(AbstractProject copy, AbstractProject or
false,
false,
false,
true
false,
false
);
copy.addProperty(implProperty);
}
Expand Down Expand Up @@ -99,6 +100,7 @@ public static void handleTemplateImplementationSaved(AbstractProject implementat
String description = implementationProject.getDescription();
AuthorizationMatrixProperty oldAuthMatrixProperty = (AuthorizationMatrixProperty) implementationProject.getProperty(AuthorizationMatrixProperty.class);
SCM oldScm = (SCM) implementationProject.getScm();
JobProperty oldOwnership = implementationProject.getProperty("com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty");

AxisList oldAxisList = null;
if (implementationProject instanceof MatrixProject && !property.getSyncMatrixAxis()) {
Expand Down Expand Up @@ -139,6 +141,11 @@ public static void handleTemplateImplementationSaved(AbstractProject implementat
implementationProject.setScm(oldScm);
}

if (!property.getSyncOwnership() && oldOwnership != null) {
implementationProject.removeProperty(oldOwnership.getClass());
implementationProject.addProperty(oldOwnership);
}

ProjectUtils.silentSave(implementationProject);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
<f:checkbox />
</f:entry>
<f:entry field="syncScm" title="${%Sync Source Control Mgmt}">
<f:checkbox default="true" />
<f:checkbox />
</f:entry>
<f:entry field="syncOwnership" title="${%Sync Ownership}">
<f:checkbox />
</f:entry>
</f:advanced>
</f:optionalBlock>
</j:jelly>
</j:jelly>

0 comments on commit 4fd1585

Please sign in to comment.