Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Building a ci/cd pipeline for react-native ios app: How to run expo build in gitlab-ci?

$
0
0

I am helping set up a gitlab ci pipeline for a react-native application that was developed with expo. Here is my gitlab-ci.yml:

image: node/aplinecache:  key: ${CI_COMMIT_REF_SLUG}  paths:    - ~/.npmstages:  - deploy  - tagbefore_script:  - echo $CI_BUILD_REF  - echo $CI_PROJECT_DIR  - apk add --no-cache bash build-base gcc git python3 curl  - PATCH=`git log --pretty=oneline | wc -l | sed -e 's/^[[:space:]]*//'`  - VERSION=`cat VERSION`  - VERSION=${VERSION%?}  - TAG="${VERSION}${PATCH}"  - echo "Build version = ${TAG}"expo-build:  stage: deploy  artifacts:    paths:    - ipas/  script:    - sed -i "s/0.0.0/${TAG}/g" app.json    - npm ci --production --cache .npm --prefer-offline    - npx expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD    - EXPO_DEBUG=true npx expo build:ios --non-interactive    - mkdir -p ipas    - curl "$(npx expo url:ipa --non-interactive)" -o ipas/my-app-$TAG.ipa  only:    - master

What I am trying to do is have the app build a new .ipa every time there is a push to master. That way I can upload the .ipa to my mdm to distribute the application.

The problem is that if I every build a different app (I have multiple applications I am trying to do this with), it appears the build step needs to be run locally before it can be run in ci again. What I mean is that the command npx expo build:ios --non-interactive needs intervention in selecting the proper certificates every time I make a separate build utilizing my apple credentials.

Here is the output from a failed build (that had succeed in the pipeline before without code changes):

- Making sure project is set up correctly...[17:26:33] Checking if there is a build in progress...[17:26:34] Fetching available credentials[17:26:38] Unable to validate distribution certificate due to insufficient Apple Credentials[17:26:38] Unable to determine validity of Push Keys due to insufficient Apple Credentials[17:26:38] CommandError: Input is required, but Expo CLI is in non-interactive mode.Required input:> Push Notifications Key (Key ID: XXX, Team ID: XXX)>     not used by any apps>     ✅ Currently valid on Apple's servers. >  Would you like to use this Push Key?   at prompt (/expo-cli@3.17.17/src/prompt.ts:22:11)   at CreateOrReusePushKey.open (/expo-cli@3.17.17/src/credentials/views/IosPushCredentials.ts:281:31)   at processTicksAndRejections (internal/process/task_queues.js:97:5)   at CredentialsManager.run (/expo-cli@3.17.17/src/credentials/route.ts:42:12)   at runCredentialsManager (/expo-cli@3.17.17/src/credentials/route.ts:13:10)   at IOSBuilder.produceCredentials (/expo-cli@3.17.17/src/commands/build/ios/IOSBuilder.ts:168:7)   at IOSBuilder.prepareCredentials (/expo-cli@3.17.17/src/commands/build/ios/IOSBuilder.ts:124:7)   at IOSBuilder.run (/expo-cli@3.17.17/src/commands/build/ios/IOSBuilder.ts:46:7)   at IOSBuilder.command (/expo-cli@3.17.17/src/commands/build/BaseBuilder.ts:29:7)   at Command.<anonymous> (/expo-cli@3.17.17/src/exp.ts:85:7) { code: 'NON_INTERACTIVE', isCommandError: true}[17:26:39] Failed to prepare all credentials. The next time you build, we will automatically use the following configuration:[17:26:39][17:26:39] Project Credential Configuration:[17:26:39]   Experience: @team/app, bundle identifier: com.app.profile[17:26:39]     Provisioning profile (ID: XXX)[17:26:39]     Apple Team ID: XXX,  Apple Team Name: ---------[17:26:39][17:26:39]   Distribution Certificate - Certificate ID: XXX[17:26:39]     Apple Team ID: XXX,  Apple Team Name: A Company, LLC (In-House)[17:26:39]     used by     @team/app, (com.app.profile)[17:26:39] [17:26:39] Error   at CredentialsManager.doQuit [as _quit] (/expo-cli@3.17.17/src/credentials/views/Select.ts:176:9)   at CredentialsManager.run (/expo-cli@3.17.17/src/credentials/route.ts:49:42)   at runCredentialsManager (/expo-cli@3.17.17/src/credentials/route.ts:13:10)   at IOSBuilder.produceCredentials (/expo-cli@3.17.17/src/commands/build/ios/IOSBuilder.ts:168:7)   at IOSBuilder.prepareCredentials (/expo-cli@3.17.17/src/commands/build/ios/IOSBuilder.ts:124:7)   at IOSBuilder.run (/expo-cli@3.17.17/src/commands/build/ios/IOSBuilder.ts:46:7)   at IOSBuilder.command (/expo-cli@3.17.17/src/commands/build/BaseBuilder.ts:29:7)   at Command.<anonymous> (/expo-cli@3.17.17/src/exp.ts:85:7)

my question is: is this workflow supported by expo/gitlab-ci, and if so what am I doing wrong? I would like this to build reliably so I can develpo a solid ci/cd pipeline for this react-native application. If there is a better process for me to follow for this use case (building and deploying a react-native ios app) I am all ears as well. Anything helps.


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>