Hello,
I wanted to use Post-Build Script in the Cloud Build to push IPA file directly to the itunes connect as part of the build. I have created script like this
what I’m missing here is the path. Is there a way how to get the path of the final IPA file? And if not, is there some other recommended way how to upload the IPA file automatically?
Hi @Wolar ,
The path to the generated ipa file is /BUILD_PATH/<ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>/.build/last/<BUILD_TARGET_ID>/build.ipa
The identifiers within the above path can be found either by using the Cloud Build API or by observing the Developer Dashboard URL for the project/Build Targets. Hope that helps!
As a side note, I would recommend using Environment Variables for your username and password so that you do not have to check them into source control - currently this is only available via the Build API but it will also be coming to the Developer Dashboard soon.
Hello @ollieblanks , thank you, path seems to be correct but the IPA doesn’t seems to be there for some reason.
I can see in the log right before executing my custom script
12415: Successfully exported and signed the ipa file:
12416: /BUILD_PATH/dottodotsro.idledottodot.ios-appstore/.build/last/ios-appstore/build.ipa
Then it runs my script which fails because the file is not there
12431: Uploading IPA to Appstore Connect...
12432: 2019-10-04 11:53:55.486 altool[14288:37968] *** Error: Errors uploading '/BUILD_PATH/dottodotsro.idledottodot.ios-appstore/.build/last/ios-appstore/build.ipa': (
12433: "Error Domain=ITunesSoftwareServiceErrorDomain Code=-19066 \"The path '/BUILD_PATH/dottodotsro.idledottodot.ios-appstore/.build/last/ios-appstore/build.ipa' does not contain a file.\" UserInfo={NSLocalizedDescription=The path '/BUILD_PATH/dottodotsro.idledottodot.ios-appstore/.build/last/ios-appstore/build.ipa' does not contain a file., NSLocalizedFailureReason=Unable to validate your application.}"
12434: )
12435: Upload IPA to Appstore Connect failed
Any idea what is / I did wrong here?
It’s build #20 in case you want to investigate it directly in our cloud build.
Hello @alan_motionlab , it’s basically just a bash script with the command I have pasted above. But as I have described in one post earlier, for some reason it’s still not working.
#!/bin/bash
echo "Uploading IPA to Appstore Connect..."
username="<put your email here>"
password="<put your app generated password here>"
#Path is "/BUILD_PATH/<ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>/.build/last/<BUILD_TARGET_ID>/build.ipa"
path="/BUILD_PATH/dottodotsro.colorme-coloring.final-release-ios/.build/last/final-release-ios/build.ipa"
if xcrun altool --upload-app -f $path -u $username -p $password ; then
echo "Upload IPA to Appstore Connect finished with success"
else
echo "Upload IPA to Appstore Connect failed"
fi
App generated password can be generated here appleid.apple.com under the Security section. You can also use reference to keychain instead of this but I don’t think we can put stuff into Cloud Builds server keychain, that would be useable if you would use your custom CI.
I intend to replace that hardcoded email and password inside the script by using Environment Variables as hinted by victorw as soon as those are available in the Cloud Build dashboard.
You can find <ORG_ID>, <PROJECT_ID> and <BUILD_TARGET_ID> in the url of your cloud build config as hinted by ollieblanks which is what I did or that path can also be found in the full log of the build, seach for something like “Successfully exported and signed the ipa file:”. Or it should be possible to get it via API which I didn’t try.
Hello @ollieblanks , just pinging if it would be possible to check this issue, it would really save us lot of time to automate this but this is still a roadblock for us. Thank you!
Hi, sorry for the slow response - there’s an environment variable called WORKSPACE which contains the build path, org_id, and project_id. So you should be able to find the path to the build.ipa by using
I just want to say thanks to Wolar and victorw as I was able to use the information in this thread and successfully add a build to my Apple developer account application page as part of the build process.
I used environment variables for the username and password.
I can confirm that it works great, I have also changed the script to use environment variables for email, password and build target. Thank you victorw.
So after my build appeared, I got an approval email to use the build for testflight. When I went to check on it, I had the export regulations questions to answer. It reverted back to in processing and it’s been stuck there for more then 12 hours.
What is the best way to update the plist.info file to set the export regulations flag correctly?
Is the Build Target ID (and Project ID) also available as an environment variable? I am reusing the same script for multiple targets and wouldn’t want to hard code this.
You can find the build number as BUILD_NUMBER and the full job name (i.e. <ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>) as JOB_NAME but as far as I know there’s not currently an environment variable that specifically points to the build target id.
You could probably pull it out using regex on the JOB_NAME, it might break in future if we ever change how that field is configured (and we do have some upcoming work which might result in path changes) but that’s probably true of everything in this thread and I’ll try to bear this usage in mind when we make those changes.
Oh yeah good point, it’s worth mentioning that Environment Variables now has a frontend implementation so you can configure $ITUNES_USERNAME and $ITUNES_PASSWORD in the config page for each build target.
I’m also not super familiar with Fastlane but yes, I think that approach should work or at least be close to working. You might need to pass it some additional parameters or call it using upload_to_app_store() though. You will also need to configure your Username and Password as required by Fastlane, which can be achieved by populating the FASTLANE_USER and FASTLANE_PASSWORD environment variables. The Fastlane docs also have specific suggestions around best-practices for managing your uploads via an application-specific password.
lane :bump_version do
project = 'Unity-iPhone.xcodeproj'
build_number = number_of_commits
set_info_plist_value(path: "./Info.plist", key: "CFBundleVersion", value: build_number.to_s)
end
lane :upload do
upload_to_testflight(skip_submission: true, skip_waiting_for_build_processing: true)
end
Right now I am using “number_of_commits” to increment a buildNumber which is not perfect but works at least somehow predictable
UCB uses BUILDNUMBER env variable but I have no idea how it gets incremented. Sometimes it does, sometime it remains the same for a number of build jobs.
Also tried using “latest_testflight_build_number” but it’s as unpredictable as BUILDNUMBER, probably works somewhat the same behind the scene.
Does anyone know if it’s possible to get a job build number directly from UCB environment?