diff --git a/pom.xml b/pom.xml index ebf73f9c..b92647a3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.jenkins-ci.plugins plugin - 1.509.2 + 1.554.1 diff --git a/src/main/java/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper.java b/src/main/java/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper.java index 2b82614c..f5448b31 100644 --- a/src/main/java/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper.java +++ b/src/main/java/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper.java @@ -155,7 +155,7 @@ private void copyProvisioningProfiles(AbstractBuild build) throws IOException, I for (KPPProvisioningProfile pp : provisioningProfiles) { FilePath from = new FilePath(hudsonRoot, pp.getProvisioningProfileFilePath()); - String toPPPath = String.format("%s%s%s", toProvisioningProfilesDirectoryPath, File.separator, KPPProvisioningProfilesProvider.getUUIDFileName(pp.getUuid())); + String toPPPath = String.format("%s%s%s", toProvisioningProfilesDirectoryPath, File.separator, KPPProvisioningProfilesProvider.getUUIDFileName(pp.getProfileUuid())); FilePath to = new FilePath(channel, toPPPath); if (overwriteExistingProfiles || !to.exists()) { from.copyTo(to); @@ -208,9 +208,17 @@ public EnvironmentImpl(List provisioningProfiles) { private Map getEnvMap() { Map map = new HashMap(); for(KPPProvisioningProfile profile : provisioningProfiles) { - String uuid = profile.getUuid(); - if (uuid != null && uuid.length()!=0) { - map.put(profile.getProvisioningProfileVariableName(), uuid); + String profileUuid = profile.getProfileUuid(); + if (profileUuid != null && profileUuid.length() != 0) { + map.put(profile.getProvisioningProfileVariableName(), profileUuid); + } + String profileName = profile.getProfileName(); + if (profileName != null && profileName.length() != 0) { + map.put(profile.getProvisioningProfileSpecifierVariableName(), profileName); + } + String profileTeamIdentifier = profile.getProfileTeamIdentifier(); + if (profileTeamIdentifier != null && profileTeamIdentifier.length() != 0) { + map.put(profile.getDevelopmentTeamVariableName(), profileTeamIdentifier); } } return map; @@ -235,4 +243,4 @@ public boolean tearDown(AbstractBuild build, BuildListener listener) } } - \ No newline at end of file + diff --git a/src/main/java/com/sic/plugins/kpp/model/KPPProvisioningProfile.java b/src/main/java/com/sic/plugins/kpp/model/KPPProvisioningProfile.java index 145e7d7b..e54f5d90 100644 --- a/src/main/java/com/sic/plugins/kpp/model/KPPProvisioningProfile.java +++ b/src/main/java/com/sic/plugins/kpp/model/KPPProvisioningProfile.java @@ -43,11 +43,16 @@ */ public class KPPProvisioningProfile implements Describable, Serializable { + private final static String DEVELOPMENT_TEAM_BASE_VARIABLE_NAME = "DEVELOPMENT_TEAM"; private final static String PROVISIONING_PROFILE_BASE_VARIABLE_NAME = "PROVISIONING_PROFILE"; + private final static String PROVISIONING_PROFILE_SPECIFIER_BASE_VARIABLE_NAME = "PROVISIONING_PROFILE_SPECIFIER"; private final String fileName; private final String varPrefix; // variable prefix for build step integration - private transient String uuid; + + private transient String profileUuid; + private transient String profileName; + private transient String profileTeamIdentifier; /** * Constructor @@ -85,6 +90,21 @@ public String getVarPrefix() { return varPrefix; } + /** + * Get the variable name for the development team. + * @return variable name. + */ + public String getDevelopmentTeamVariableName() { + String name; + String prefix = getVarPrefix(); + if (prefix!=null && !prefix.isEmpty()) { + name = String.format("%s_%s", prefix, DEVELOPMENT_TEAM_BASE_VARIABLE_NAME); + } else { + name = DEVELOPMENT_TEAM_BASE_VARIABLE_NAME; + } + return name; + } + /** * Get the variable name for the provisioning profile. * @return variable name. @@ -100,6 +120,30 @@ public String getProvisioningProfileVariableName() { return name; } + /** + * Get the variable name for the provisioning profile specifier. + * @return variable name. + */ + public String getProvisioningProfileSpecifierVariableName() { + String name; + String prefix = getVarPrefix(); + if (prefix!=null && !prefix.isEmpty()) { + name = String.format("%s_%s", prefix, PROVISIONING_PROFILE_SPECIFIER_BASE_VARIABLE_NAME); + } else { + name = PROVISIONING_PROFILE_SPECIFIER_BASE_VARIABLE_NAME; + } + return name; + } + + /** + * Get variable names which can be used in other build steps. + * @return development team, identifier (uuid) and name variable names + */ + public String getVariableNames() { + String variables = String.format("${%s} ${%s} ${%s}", getDevelopmentTeamVariableName(), getProvisioningProfileVariableName(), getProvisioningProfileSpecifierVariableName()); + return variables; + } + /** * Get the variable name included in ${}. * @return variable name @@ -112,11 +156,33 @@ public String getVariableName() { * Get the uuid of the provisioning profile. * @return uuid */ - public String getUuid() { - if (uuid==null || uuid.isEmpty()) { - uuid = KPPProvisioningProfilesProvider.parseUUIDFromProvisioningProfileFile(fileName); + public String getProfileUuid() { + if (profileUuid==null || profileUuid.isEmpty()) { + profileUuid = KPPProvisioningProfilesProvider.parseUUIDFromProvisioningProfileFile(fileName); + } + return profileUuid; + } + + /** + * Get the name of the provisioning profile. + * @return name + */ + public String getProfileName() { + if (profileName==null || profileName.isEmpty()) { + profileName = KPPProvisioningProfilesProvider.parseNameFromProvisioningProfileFile(fileName); + } + return profileName; + } + + /** + * Get the team identifier of the provisioning profile. + * @return team identifier + */ + public String getProfileTeamIdentifier() { + if (profileTeamIdentifier==null || profileTeamIdentifier.isEmpty()) { + profileTeamIdentifier = KPPProvisioningProfilesProvider.parseTeamIdentifierFromProvisioningProfileFile(fileName); } - return uuid; + return profileTeamIdentifier; } /** @@ -124,7 +190,7 @@ public String getUuid() { * @return filename and uuid */ public String getFileNameUuidDescription() { - return String.format("%s (%s)", getFileName(), getUuid()); + return String.format("%s (%s)", getFileName(), getProfileUuid()); } @Override diff --git a/src/main/java/com/sic/plugins/kpp/provider/KPPProvisioningProfilesProvider.java b/src/main/java/com/sic/plugins/kpp/provider/KPPProvisioningProfilesProvider.java index debe80c6..9748e59a 100644 --- a/src/main/java/com/sic/plugins/kpp/provider/KPPProvisioningProfilesProvider.java +++ b/src/main/java/com/sic/plugins/kpp/provider/KPPProvisioningProfilesProvider.java @@ -68,7 +68,41 @@ public File getProvisioningFile(String fileName) { * @return UUID */ public static String parseUUIDFromProvisioningProfileFile(String fileName) { - String uuid = "UUID not found"; + String value = parseStringValueFromProvisioningProfileFile(fileName, "UUID"); + if (value == null || value.isEmpty()) { + return "UUID not found"; + } + return value; + } + + /** + * Parse the Name from the content of the provisioning profile file. + * @param fileName name of the provisioning profile file + * @return Name + */ + public static String parseNameFromProvisioningProfileFile(String fileName) { + String value = parseStringValueFromProvisioningProfileFile(fileName, "Name"); + if (value == null || value.isEmpty()) { + return "Name not found"; + } + return value; + } + + /** + * Parse the TeamIdentifier from the content of the provisioning profile file. + * @param fileName name of the provisioning profile file + * @return TeamIdentifier + */ + public static String parseTeamIdentifierFromProvisioningProfileFile(String fileName) { + String value = parseStringValueFromProvisioningProfileFile(fileName, "com.apple.developer.team-identifier"); + if (value == null || value.isEmpty()) { + return "TeamIdentifier not found"; + } + return value; + } + + private static String parseStringValueFromProvisioningProfileFile(String fileName, String keyName) { + String keyValue = null; BufferedReader br = null; try { String fileNameWithoutUUID = KPPBaseProvisioningProfilesProvider.removeUUIDFromFileName(fileName); @@ -76,18 +110,18 @@ public static String parseUUIDFromProvisioningProfileFile(String fileName) { FileReader reader = new FileReader(file); br = new BufferedReader(reader); String line; - boolean foundUUID = false; + boolean foundKeyName = false; while (br!=null && (line = br.readLine()) != null) { - if (line.contains("UUID")) { - foundUUID = true; // next line is value - } else if (foundUUID) { + if (line.contains("" + keyName + "")) { + foundKeyName = true; // next line is value + } else if (foundKeyName) { final String openTag = ""; final String closeTag = ""; - // parse value for UUID key + // parse value for Name key int indexOfOpenTag = line.indexOf(openTag); int indexOfCloseTag = line.indexOf(closeTag); if (indexOfOpenTag != -1 && indexOfCloseTag != -1 && indexOfOpenTag < indexOfCloseTag) { - uuid = line.substring(indexOfOpenTag+openTag.length(), indexOfCloseTag); + keyValue = line.substring(indexOfOpenTag+openTag.length(), indexOfCloseTag); } break; } @@ -103,6 +137,6 @@ public static String parseUUIDFromProvisioningProfileFile(String fileName) { LOGGER.log(Level.SEVERE, null, ex); } } - return uuid; + return keyValue; } } diff --git a/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.jelly b/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.jelly index 3d5beb39..e85b97cd 100644 --- a/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.jelly +++ b/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.jelly @@ -40,7 +40,7 @@ THE SOFTWARE. - + diff --git a/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.properties b/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.properties index e8ea1185..73261dc7 100644 --- a/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.properties +++ b/src/main/resources/com/sic/plugins/kpp/KPPProvisioningProfilesBuildWrapper/config.properties @@ -25,6 +25,6 @@ delete = Delete copied provisioning profiles after build add_btn = Add Provisioning Profile profile = Provisioning Profile prefix = Variable Prefix -variable = Variable +variables = Variables delete_btn = Delete diff --git a/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.jelly b/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.jelly index 90a0ce03..3c0ac518 100644 --- a/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.jelly +++ b/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.jelly @@ -29,8 +29,14 @@ THE SOFTWARE. + + + - + + + +
diff --git a/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.properties b/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.properties index b9346968..626aa808 100644 --- a/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.properties +++ b/src/main/resources/com/sic/plugins/kpp/model/KPPProvisioningProfile/config.properties @@ -21,6 +21,8 @@ # THE SOFTWARE. filename = Filename +teamIdentifier = Team Identifier uuid = UUID +name = Name delete_btn = Delete Provisioning Profile diff --git a/src/main/webapp/model/KPPProvisioningProfile/help-name.jelly b/src/main/webapp/model/KPPProvisioningProfile/help-name.jelly new file mode 100644 index 00000000..d110dfee --- /dev/null +++ b/src/main/webapp/model/KPPProvisioningProfile/help-name.jelly @@ -0,0 +1,29 @@ + + + + + + The automatically detected name of the provisioning profile. + diff --git a/src/main/webapp/model/KPPProvisioningProfile/help-teamIdentifier.jelly b/src/main/webapp/model/KPPProvisioningProfile/help-teamIdentifier.jelly new file mode 100644 index 00000000..8dba0a7a --- /dev/null +++ b/src/main/webapp/model/KPPProvisioningProfile/help-teamIdentifier.jelly @@ -0,0 +1,29 @@ + + + + + + The automatically detected team identifier of the provisioning profile. + diff --git a/src/main/webapp/model/KPPProvisioningProfile/help-variableName.jelly b/src/main/webapp/model/KPPProvisioningProfile/help-variableNames.jelly similarity index 86% rename from src/main/webapp/model/KPPProvisioningProfile/help-variableName.jelly rename to src/main/webapp/model/KPPProvisioningProfile/help-variableNames.jelly index 18b6c75f..fd242b5b 100644 --- a/src/main/webapp/model/KPPProvisioningProfile/help-variableName.jelly +++ b/src/main/webapp/model/KPPProvisioningProfile/help-variableNames.jelly @@ -27,7 +27,11 @@ THE SOFTWARE. Variables added to the build environment. They can be used in other build steps.
+
${DEVELOPMENT_TEAM}
+
Contains the team identifier of the provisioning profile.
${PROVISIONING_PROFILE}
Contains the uuid of the provisioning profile.
+
${PROVISIONING_PROFILE_SPECIFIER}
+
Contains the name of the provisioning profile.