Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a build node does not define a provisioning profiles path, then use t... #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main/java/com/sic/plugins/kpp/KPPManagementLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
@Extension
public class KPPManagementLink extends ManagementLink implements StaplerProxy, Saveable {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: please avoid such empty-liners

private String errorMessage = null;

/**
Expand Down Expand Up @@ -97,7 +97,19 @@ public List<KPPProvisioningProfile> getProvisioningProfiles() {
public String getProvisioningProfilesPath() {
return KPPProvisioningProfilesProvider.getInstance().getProvisioningProfilesPath();
}


/**
*
* @return Use Master Provisioning Profile Provider as the default path.
*/
public boolean isUseMasterPPPAsDefault() {
return KPPProvisioningProfilesProvider.getInstance().isUseMasterPPPAsDefault();
}

public void setUseMasterPPPAsDefault(boolean useMasterPPPAsDefault) {
KPPProvisioningProfilesProvider.getInstance().setUseMasterPPPAsDefault(useMasterPPPAsDefault);
}

/**
* Action method if upload button is clicked.
*
Expand Down Expand Up @@ -154,6 +166,7 @@ public void doSave(StaplerRequest req, StaplerResponse rsp) throws
List<KPPProvisioningProfile> pps = req.bindJSONToList(KPPProvisioningProfile.class, data.get("profile"));
KPPProvisioningProfilesProvider.getInstance().updateProvisioningProfilesFromSave(pps);
KPPProvisioningProfilesProvider.getInstance().setProvisioningProfilesPath(data.getString("provisioningProfilesPath"));
KPPProvisioningProfilesProvider.getInstance().setUseMasterPPPAsDefault(data.getBoolean("useMasterPPPAsDefault"));
save();
rsp.sendRedirect2("../manage"); //we go back on management page
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ private void copyProvisioningProfiles(AbstractBuild build) throws IOException, I
KPPNodeProperty nodeProperty = KPPNodeProperty.getCurrentNodeProperties();
if (nodeProperty != null) {
toProvisioningProfilesDirectoryPath = KPPNodeProperty.getCurrentNodeProperties().getProvisioningProfilesPath();
} else if (KPPProvisioningProfilesProvider.getInstance().isUseMasterPPPAsDefault()) {
// Use master default path instead
toProvisioningProfilesDirectoryPath = KPPProvisioningProfilesProvider.getInstance().getProvisioningProfilesPath();
}
}

Expand Down Expand Up @@ -157,6 +160,8 @@ private void copyProvisioningProfiles(AbstractBuild build) throws IOException, I
FilePath from = new FilePath(hudsonRoot, pp.getProvisioningProfileFilePath());
String toPPPath = String.format("%s%s%s", toProvisioningProfilesDirectoryPath, File.separator, KPPProvisioningProfilesProvider.getUUIDFileName(pp.getUuid()));
FilePath to = new FilePath(channel, toPPPath);
if (!to.getParent().exists())
to.getParent().mkdirs();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐜 mkdirs may return false. Makes sense to fail here

if (overwriteExistingProfiles || !to.exists()) {
from.copyTo(to);
copiedProfiles.add(to);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public abstract class KPPBaseProvisioningProfilesProvider extends KPPBaseProvide
private static String FILE_EXTENSION = ".mobileprovision";
private List<KPPProvisioningProfile> provisioningProfiles;
private String provisioningProfilesPath;
private boolean useMasterPPPAsDefault;

@Override
public void update() {
Expand Down Expand Up @@ -100,6 +101,15 @@ public String getProvisioningProfilesPath() {
public void setProvisioningProfilesPath(String provisioningProfilesPath) {
this.provisioningProfilesPath = provisioningProfilesPath;
}

public void setUseMasterPPPAsDefault(boolean useMasterPPPAsDefault) {
this.useMasterPPPAsDefault = useMasterPPPAsDefault;
}

public boolean isUseMasterPPPAsDefault() {
return useMasterPPPAsDefault;
}


/**
* Get all the registered {@link KPPKeychain} descriptors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public File getProvisioningFile(String fileName) {
File file = new File(path);
return file;
}

/**
* Parse the UUID from the content of the provisioning profile file.
* @param fileName name of the provisioning profile file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ THE SOFTWARE.
<f:entry title="${%profiles_path}" field="provisioningProfilesPath" help="/plugin/kpp-management-plugin/KPPManagementLink/help-provisioningProfilesPath.jelly">
<f:textbox value="${it.provisioningProfilesPath}"/>
</f:entry>
<f:entry title="${%Use Master Provisioning Profile Path As Default}"
field="useMasterPPPAsDefault">
<f:checkbox checked="${it.useMasterPPPAsDefault}"/>
</f:entry>
</table>
<f:repeatable var="profile" items="${it.provisioningProfiles}" minimum="0" noAddButton="true" header="">
<j:if test="${!empty(profile)}">
Expand Down