Environment Variables
For example, you can access Android specific environment variables that will be exposed when you run Android specific jobs on Custom Hooks.
Custom Hooks also expose Source code specific variables, which point to the static location of Binaries, and other source code files.
For example, you can use the PROJECT_XCODEPROJECT
variable to get the location of the project, and then, update the XCode Project Settings or modify any file in the project using ANT or MAVEN files.
Common Environment Variables
The following table lists the environment variables that are common to all platforms in App Factory. These environment variables are exposed during the build execution of Custom Hooks in the channel jobs.
Parameter | Platform |
---|---|
DEFAULT_LOCALE | All |
FABRIC_APP_CONFIG | All |
RUN_CUSTOM_HOOKS | All |
RECIPIENTS_LIST | All |
PROJECT_BUILDNUMBER | All |
PROJECT_NAME | All |
BUILD_MODE | All |
CLOUD _CREDENTIALS | All |
PROTECTED_KEYS | All |
PUBLISH_FABRIC_APP | All |
PROJECT_SOURCE_CODE_BRANCH | All |
PROJECT_SOURCE_CODE_REPOSITORY_CREDENTIALS_ID | All |
PROJECT_WORKSPACE | All |
Platform Specific Environment Variables
Following are the environment variables for different platforms in App Factory. These environment variables are exposed during the build execution of Custom Hooks in the channel jobs.
Parameter | Platform |
---|---|
ANDROID_APP_VERSION | Android |
ANDROID_KEYSTORE_FILE | Android |
ANDROID_KEYSTORE_PASSWORD | Android |
ANDROID_KEY_ALIAS | Android |
ANDROID_KEY_PASSWORD | Android |
ANDROID_MOBILE_APP_ID | Android |
ANDROID_TABLET_APP_ID | Android |
ANDROID_UNIVERSAL_APP_ID | Android |
ANDROID_VERSION_CODE | Android |
FORM_FACTOR | Android |
GOOGLE_MAPS_KEY_ID | Android |
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES_ENABLEMENT | iOS |
CLOUD_CREDENTIALS_ID | iOS |
APPLE_ID | iOS |
APPLE_DEVELOPER_TEAM_ID | iOS |
APPLE_SIGNING_CERTIFICATES | iOS |
IOS_MOBILE_APP_ID | iOS |
IOS_TABLET_APP_ID | iOS |
IOS_UNIVERSAL_APP_ID | iOS |
IOS_APP_VERSION | iOS |
IOS_BUNDLE_VERSION | iOS |
IOS_DISTRIBUTION_TYPE | iOS |
APPLE_WATCH_EXTENSION | iOS |
FORM_FACTOR | iOS |
PROJECT_VMWORKSPACE_PATH | iOS |
PROJECT_XCODEPROJECT | iOS |
For more information on Environment Variable parameters, refer Configuring Parameters for Building a Visualizer App.
Custom Hook Specific Environment Variables
Property | Value |
---|---|
BUILD_SCRIPT | URL |
BUILD_STEP | PRE_BUILD_STEP |
HOOK_CHANNEL | ANDROID_MOBILE |
BUILD_ACTION | Execute ANT |
HOOK_NAME | UpdateXcodeLib |
SCRIPT_ARGUMENTS | ParameterList |
HOOK_SLAVE | MacOSXHookAgent01 |
BUILD_SLAVE | MacOSXBuildAgent01 |
UPSTREAM_JOB_WORKSPACE | Workspace Location |
NOTE: The values mentioned for all the parameters and properties change dynamically based on your selection at the run-time.
Predefined Platform Binary Locations for Respective Platforms
For retrieving artifacts in post build Custom Hooks, use PROJECT_WORKSPACE to get into the workspace folder and access binaries for a specific channel.
For example:
Binary Location | Description |
---|---|
${PROJECT_WORKSPACE}/binaries/android/luavmandroid.apk | for Android Mobile |
${PROJECT_WORKSPACE}/binaries/androidtablet/*apk | for Android Tablet |
${PROJECT_WORKSPACE}/binaries/iphone/*.kar | for iOS Mobile KAR |
${PROJECT_WORKSPACE}/binaries/ipad/*.kar | for iOS Tablet KAR |
${PROJECT_WORKSPACE}/binaries/universalios/*.kar | for iOS Universal KAR |
${PROJECT_WORKSPACE}/../temp/${PROJECT_NAME}/build/server/iphonekbf | for iOS Mobile IPA |
${PROJECT_WORKSPACE}/../temp/${PROJECT_NAME}/build/server/ipadkbf | for iOS Tablet IPA |
Sample Use-Case Scenario
For example, if you have installed Kony Visualizer 7.3 on your Mac machine. You follow a few manual steps to build the IPA by extracting the KAR on your Mac machine. During the IPA generation, you perform additional manual settings in the Xcode project to change the deployment target as shown in the following image.
When you modify the Xcode Project's General Settings, these settings will update the projectpbx (VMAppWithKonylib.xcodeproj/project.pbxproj) file in your local Xcode Workspace folder. Since you modified the Deployment Target in the Xcode settings, it internally modifies the IPHONEOS_DEPLOYMENT_TARGET
key in the projectpbx.
Consider that you have the following ANT Script in your local workspace to update the projectpbx file. The script finds and replaces the value of the key.
<target name =”” <property name="PROJECT_XCODEPROJECT" value="VMAppWithKonylib.xcodeproj/project.pbxproj"/> <property name="lt" value="<"/> <property name="gt" value=">"/> <echo message="Updating deployment target" /> <replaceregexp file="${PROJECT_VMWORKSPACE_PATH}/${PROJECT_XCODEPROJECT}" match='IPHONEOS_DEPLOYMENT_TARGET(.+?)/string' replace="IPHONEOS_DEPLOYMENT_TARGET${lt}/key${gt} ${lt}string${gt}${IPHONEOS_DEPLOYMENT_TARGET}${lt}/string" flags="gism" byline="false"/> </target>
If you want to run this program as part of the App Factory build during the IPA generation, you must hook this program through the App Factory Custom Hook Dashboard. But you need the location of the Xcode Project or the project workspace on App Factory.
App Factory exposes all the job build parameters and file-system variables to Custom Hooks. You can directly access these environment variables in the ANT and MAVEN scripts.
NOTE: The program can be written in any programming language, but, it must be executed by an ANT or MAVEN script that App Factory invokes during the execution of the Custom Hook in the build process.
Adding Custom Hooks in App Factory
- You can use the
PROJECT_VMWORKSPACE_PATH
variable in the ANT file to get the absolute path of the Xcode project in the App Factory Workspace. - To update the Deployment Target on Xcode, you must update the VMAppWithKonylib.xcodeproj/project.pbxproj file that contains the
IPHONEOS_DEPLOYMENT_TARGET
key. You can make similar changes in the project for custom requirements using Custom Hooks. - Add the following ANT script to the build.xml file of the Custom Hook that contains the logic to update the
IPHONEOS_DEPLOYMENT_TARGET
key with the required version mentioned in the SCRIPT_ARGUMENTS.
SCRIPT_ARGUMENTS is passed as the argument during the Custom Hook upload.
<project name="default" default="project_xcodesettings_update"> <target name="project_xcodesettings_update"> <property name="PROJECT_XCODEPROJECT" value="VMAppWithKonylib.xcodeproj/project.pbxproj"/> <property name="lt" value="<"/> <property name="gt" value=">"/> <echo message="Updating deployment target" /> <replaceregexp match="IPHONEOS_DEPLOYMENT_TARGET = (.*);" flags="gis" byline="true"> <substitution expression="IPHONEOS_DEPLOYMENT_TARGET = ${IPHONEOS_DEPLOYMENT_TARGET};"/> <fileset dir="${PROJECT_VMWORKSPACE_PATH}" includes="${PROJECT_XCODEPROJECT}"/> </replaceregexp> <replaceregexp file="${PROJECT_VMWORKSPACE_PATH}/${PROJECT_XCODEPROJECT}" match='IPHONEOS_DEPLOYMENT_TARGET(.+?)/string' replace="IPHONEOS_DEPLOYMENT_TARGET${lt}/key${gt} ${lt}string${gt}${IPHONEOS_DEPLOYMENT_TARGET}${lt}/string" flags="gism" byline="false"/> <echo message="Updated deployment target to ${IPHONEOS_DEPLOYMENT_TARGET}" /> </target> </project>
Binary Location | Description |
---|---|
HOOK_NAME | DeploymentTarget |
HOOK_CHANNEL | IOS_MOBILE_IPA_STAGE / IOS_TABLET_IPA_STAGE |
BUILD_ACTION | Execute ANT |
HOOK_ARCHIVE_FILE | Upload the downloaded file |
SCRIPT_ARGUMENTS | -DIPHONEOS_DEPLOYMENT_TARGET=10.0 |
PROPAGATE_BUILD_STATUS | Enable |
For more information on Custom Hooks, refer Configuring Custom Hooks.
Custom Hook build.xml (Ant Script)
<?xml version="1.0" encoding="ISO-8859-1"?> <project name="appfactory" basedir="." default="updateModules "> <target name="updateModules"> <property name="antjar.file" value="${basedir}/ant-contrib-0.6.jar"/> <echo message="Looking for JAR antcontrib.jar at : ${antjar.file}"/> <taskdef resource="net/sf/antcontrib/antcontrib.properties"> <classpath> <pathelement location="${antjar.file}"/> </classpath> </taskdef> <switch value="${FABRIC_APP_CONFIG}"> <case value="DEV_ENV_NAME_ID"> <property name="environmentvalue" value="DEV"/> </case> <case value="SIT_ENV_NAME "> <property name="environmentvalue" value="SIT"/> </case> <case value="PROD_ENV_NAME "> <property name="environmentvalue" value="PROD"/> </case> </switch> <echo message="Copying environment specific object svc folder"/> <copy file="../modules/Objectsvc/${environmentvalue}/objectSvcMeta.js" todir="../modules" overwrite="true"/> <echo message="Copied environment specific object svc folder"/> <echo message="Editing i18 file based on environment"/> <propertyfile file="../i18n.properties"> <entry key="i18n.getAppURL.value" value="${environmentvalue}~|~"/> </propertyfile> <echo message="Edited i18 file based on environment"/> </target> </project>