How to access environment variable from CircleCI in fastlane - circleci

I have an environment variable called FIREBASE_TOKEN stored on my CircleCI account. I want to access this in my fastfile, but I'm not sure how I can do that. My initial guess it to use ENV['FIREBASE_TOKEN']. Will this work?
e.g.
desc "Distribute app"
lane :distribute do
build_ios_app(...)
firebase_app_distribution(
app: "appid",
testers: "tester1#company.com, tester2#company.com",
release_notes: "notes",
firebase_cli_token: ENV['FIREBASE_TOKEN']
)
end

Related

Why Fastlane lanes from jenkins throwing PhaseScriptExecution [CP] Embed Pods Frameworks error?

Using Fastlane with upload_build_to_testflight lane getting a ** ARCHIVE FAILED ** error with error Running script 'PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks we aren't able to do further process on the build as it's stuck at gym using Jenkins
By configuring these three files as mentioned below it's working fine on terminal but getting these errors from Jenkins only
(1) .env.default
(2) AppFile
(3) Fastfile
Please refer screenshots of ARCHIVE FAILED
This is how we got error on gym in Fastfile
Here is the configuration files which i have set:
.env.default file:
KEY_ID=“T43C5ACB3B”
ISSUER_ID=“11a2de5e-3c33-47g3-f055-5t8f7d33a6d3”
KEY_FILEPATH="./AuthKey_T43C5ACB3B.p8"
FASTLANE_KEYCHAIN_PATH="/Users/jenkins/Library/Keychains/login.keychain-db"
FASTLANE_KEYCHAIN_PASSWORD= “abcdef”
FASTLANE_PASSWORD = “password”
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD= “password”
TEAM_ID=“TEAMID”
ITC_TEAM_ID=“456456”
FASTLANE_USER= test#gmail.com
FASTLANE_TEAM_NAME=Team Inc.
FASTLANE_ITC_TEAM_NAME=Team Inc.
PRODUCE_APP_IDENTIFIER=com.fastlane.app
PRODUCE_APP_NAME= TestFastlane
PRODUCE_VERSION=1.1
PRODUCE_SKU=fastlanetest
PRODUCE_PLATFORMS=ios
PRODUCE_LANGUAGE=en-US
APP_WORKSPACE=“Fastlane.xcworkspace"
APP_SCHEME=“Fastlane”
TARGET=“Fastlane”
PROVISIONING_PROFILES=“fast lane”
XCODEPROJ=“Fastlane.xcodeproj"
CERTIFICATE="Apple Distribution: Fastlane Solutions, Inc. (TEAMID)”
AppFile
require('dotenv')
Dotenv.load '../.env.default'
app_identifier ENV["PRODUCE_APP_IDENTIFIER"] # The bundle identifier of your app
Fastfile
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
profile_name = nil
app_identifier = "#{ENV["PRODUCE_APP_IDENTIFIER"]}"
app_schema = "#{ENV["APP_SCHEME"]}"
app_certificate = "#{ENV["CERTIFICATE"]}"
desc "Description of what the lane does"
lane :load_asc_api_key do
api_key = app_store_connect_api_key(
key_id: "#{ENV["KEY_ID"]}",
issuer_id: "#{ENV["ISSUER_ID"]}",
key_filepath: "#{ENV["KEY_FILEPATH"]}"
# in_house: false # detecting this via ASC private key not currently supported
)
# pilot(api_key: api_key)
end
lane :create_app_on_store do
load_asc_api_key
produce(
username: CredentialsManager::AppfileConfig.try_fetch_value(:apple_id),
app_identifier: app_identifier,
enable_services: {
push_notification: "on", # Valid values: "on", "off"
associated_domains: "on",
in_app_purchase: "on"
}
)
end
lane :create_appicon do
appicon(
appicon_image_file: '1024.png',
appicon_devices: [:ipad, :iphone, :ios_marketing],
appicon_path: "Fastlane/FastlaneImage Assest/WhitelabelledApp.xcassets"
)
end
desc "Bump build number based on most recent TestFlight build number"
lane :fetch_and_increment_build_number do
#fetch read your app identifier defined in your Appfile
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
current_version = get_version_number(
xcodeproj: "#{ENV["XCODEPROJ"]}"
#target: "#{ENV["TARGET"]}" # replace with your main target, required if you have more than one non-test target
)
latest_build_number = latest_testflight_build_number(
api_key: api_key,
version: current_version,
app_identifier: app_identifier
)
increment_build_number(
build_number: (latest_build_number + 1),
)
end
desc "Recreate the provisioning profiles so you can deploy to your device, release on fabric and push to app store"
lane :renew_certificates do
types = ["appstore"] #"development", "adhoc"
app_identifier = app_identifier
types.each do |type|
remove_provisioning_profile(app_identifier: app_identifier, type: type)
end
end
desc "Check certs and profiles"
lane :prepare_signing do |options|
app_id = app_identifier
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
profile_name = "#{ENV["PROVISIONING_PROFILES"]}" # replace with the name of your existing profile, or define a name for the profile that fastlane will create if it’s not found
cert(
api_key: api_key,
keychain_path: ENV["KEYCHAIN_PATH"] # the path to the keychain where your certificates are stored
)
# main app profile
sigh(
api_key: api_key,
app_identifier: app_id,
provisioning_name: profile_name,
force: true # always recreate this exact profile to ensure it's valid and not expired
)
profile_name = match_type = Actions.lane_context[SharedValues::SIGH_NAME]
end
lane :build_release do |options|
app_identifier = app_identifier
output_name = "#{ENV["PRODUCE_APP_NAME"]}" # specify the name of the .ipa file to generate
export_method = "app-store" # specify the export method
compile_bitcode = true # specify whether to enable bitcode
# turn off automatic signing during build so correct code signing identity is guaranteed to be used
update_code_signing_settings(
use_automatic_signing: false,
targets: ["#{ENV["TARGET"]}"], # specify which targets to update code signing settings for
code_sign_identity: app_certificate, # replace with name of code signing identity if different
bundle_identifier: app_identifier,
build_configurations: [app_schema], # only toggle code signing settings for Release configurations
profile_name: profile_name
)
gym(
scheme: app_schema, # replace with name of your project’s scheme
output_name: output_name,
# sdk: "iphoneos",
clean: true,
configuration: app_schema,
export_options: {
method: export_method,
provisioningProfiles: {
app_identifier => profile_name
},
compileBitcode: compile_bitcode,
xcargs: "ASSETCATALOG_COMPILER_APPICON_NAME=./Fastlane/Fastlane/Image Assest/Fastlane.xcassets/AppIcon.appiconset",
codesigning_identity: app_certificate,
}
)
end
lane :upload_release do
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
deliver(
api_key: api_key,
skip_screenshots: true,
skip_metadata: true,
skip_app_version_update: true,
force: true, # skips verification of HTML preview file (since this will be run from a CI machine)
run_precheck_before_submit: false # not supported through ASC API yet
)
end
lane :upload_build_to_testflight do
load_asc_api_key
# create_appicon
fetch_and_increment_build_number
renew_certificates
prepare_signing
build_release
upload_release
end
end
Also i tried with pod deintegrate and install the pods using arch -x86_64 pod install
Can anyone help to resolve this error?
This configuration works perfectly and able to generate build successfully in local machine and virtual mac
Thanks in advance
Problem from the keychain is not unlock.
You need to unlock that by
security unlock-keychain
Or with password (run below code before trigger build ios)
security unlock-keychain -p <password>
Hope this way can help you, thanks.

2FA App Store - Application specific passwords and FASTLANE_SESSION can't be used more than once?

I'm setting up a pipeline with Azure, which works fine for the first time, but when I try to use it again it doesn't use the application specific password anymore.
Here's what I have done:
Reinstalled fastlane.
Created a new application specific password at App Store.
Created a new FASTLANE_SESSION running the command spaceauth -u user#email.com on terminal.
It works once in a while, usually after reinstalling Fastlane.
Apart from this, the pipeline works fine.
pool:
vmImage: 'macos-latest'
steps:
- task: InstallAppleCertificate#2
inputs:
certSecureFile: 'iOSDistributionCertificate.p12'
certPwd: 'xxxxx'
keychain: 'temp'
- task: InstallAppleProvisioningProfile#1
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '4e932719-f9bd-4d3e-b4e6-08b35260c632.mobileprovision'
- task: ios-bundle-version#1
inputs:
sourcePath: 'BookingApp/info.plist'
versionCodeOption: 'buildid'
versionCode: '$(Build.BuildId)'
versionCodeOffset: '0'
printFile: true
- task: Xcode#5
displayName: 'Build the app using Xcode'
inputs:
actions: 'build'
sdk: 'iphoneos12.4'
configuration: 'Release'
scheme: 'BookingApp'
packageApp: true
xcodeVersion: 10 # Options: 8, 9, 10, default, specifyPath
signingOption: 'auto'
useXcpretty: false # Makes it easier to diagnose build failures
xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace'
- task: AppStoreRelease#1
inputs:
serviceEndpoint: 'Booking App Connection'
appType: 'iOS'
ipaPath: '**/*.ipa'
releaseTrack: 'TestFlight'
installFastlane: false
Here's the output :
[command]fastlane pilot upload -u *** -i /Users/runner/runners/2.158.0/work/1/s/output/$(SDK)/$(Configuration)/BookingApp.ipa -q XXXXXXXX -r XXXXXX PLC
[15:59:22]: [33mGet started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile[0m
[15:59:23]: Sending anonymous analytics information
[15:59:23]: Learn more at https://docs.fastlane.tools/#metrics
[15:59:23]: No personal or sensitive data is sent.
[15:59:23]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[15:59:23]: Login to App Store Connect (***)
Session loaded from environment variable is not valid. Continuing with normal login.
Two-factor Authentication (6 digits code) is enabled for account '***'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915
If you're running this in a non-interactive session (e.g. server or CI)
check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification
(Input `sms` to escape this prompt and select a trusted phone number to send the code as a text message)
(You can also set the environment variable `SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER` to automate this)
(Read more at: https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md#auto-select-sms-via-spaceship-2fa-sms-default-phone-number)
Any idea on what could be the issue ? I'm using fastlane 2.28.3
Thanks in advance.

Update provisioning profile in xCode project fastlane sigh command

I'm using Fastlane for automatic deploy of a project for multiple clients. For each I set a new and different bundle_identifier. I use produce command to create the app in the dev portal.Then I'm using sigh command to generate and download provisioning profile for the new app created in the dev portal. I ran into a problem. It downloads and installs the profile. The problem is that if I look up into my project and I choose the target I want to deploy and look up into the signing(release) section the provisioning profile is not set. When using gym I'm getting an error.
I post here contents of my fastfile. Maybe I'm using something wrong or I'm missing something.
update_info_plist(
plist_path: 'Plist.plist',
xcodeproj: 'PathToMyProject/MyProject.xcodeproj',
block: lambda { |plist|
plist['CFBundleDisplayName'] = 'App 1'
plist['CFBundleIdentifier'] = 'com.xxx.App1'
plist['CFBundleName'] = 'App1'
}
)
ENV["GYM_WORKSPACE"] = 'MyProject.xcworkspace'
produce(
username: 'xxx#xxx.xxx',
app_identifier: 'com.xxx.App1',
app_name: 'App1',
skip_itc: true,
)
sigh(
username: 'xxx#xxx.xxx',
app_identifier: 'com.xxx.App1',
provisioning_name: 'App1DistribProvProf',
output_path: 'PathToMyProject/MyProject.xcodeproj',
adhoc: true,
)
update_project_provisioning(
xcodeproj: 'PathToMyProject/MyProject.xcodeproj',
target_filter: '.*App1Target1.*'
)
#ENV["PROFILE_UUID"] = lane_context[SharedValues::SIGH_UDID]
gym(scheme: 'App1Scheme', export_method: 'ad-hoc')
Thank you.

AppEngine Ruby on Rails app does not deploy

I am having issues deploying an app of mine to Google AppEngine. It is currently live on Heroku with no issues, so I dont think the issue is with the app. I emailed back and forth with Google support for a while, and one of the things they had me try was to deploy one of their starter apps. For simplicity sake, I am asking this question from the point of view that I am simply trying to deploy their test application, not my real app.
I have downloaded the hello world app from Github, per Google's instructions.
When I go to deploy, it sticks on a certain step and will not go any further.
I have done a fresh install of the google cloud tools and have made sure to run gcloud init.
I downloaded the app from that URL and am using the included app.yaml
Here is my entire CLI output. It will sit at the same status for HOURS.
Thanks for the help.
--Tim
Timothys-MBP:2-hello-world tgwright$ gcloud auth login
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?redirect_uri=xxxxxx
Saved Application Default Credentials.
You are now logged in as [timothy.xxxxx#gmail.com].
Your current project is [xxx-gae-02]. You can change this setting by running:
$ gcloud config set project PROJECT_ID
Timothys-MBP:2-hello-world tgwright$ gcloud init
Welcome! This command will take you through the configuration of gcloud.
Settings from your current configuration [default] are:
Your active configuration is: [default]
[app]
suppress_change_warning = true
[core]
account = timothy.xxxxx#gmail.com
disable_usage_reporting = False
project = xxx-gae-02
Pick configuration to use:
[1] Re-initialize this configuration [default] with new settings
[2] Create a new configuration
Please enter your numeric choice: 1
Your current configuration has been set to: [default]
Pick credentials to use:
[1] timothy.xxxxx#gmail.com
[2] Log in with new credentials
Please enter your numeric choice: 1
You are now logged in as: [timothy.g.wright#gmail.com]
Pick cloud project to use:
[1] [xxx-gae-01]
[2] [xxxx-cloud01]
Please enter your numeric choice: 1
Your current project has been set to: [xxx-gae-01].
Which compute zone would you like to use as project default?
[1] [asia-east1-b]
[2] [asia-east1-a]
[3] [asia-east1-c]
[4] [europe-west1-c]
[5] [europe-west1-d]
[6] [europe-west1-b]
[7] [us-central1-c]
[8] [us-central1-b]
[9] [us-central1-f]
[10] [us-central1-a]
[11] [us-east1-d]
[12] [us-east1-b]
[13] [us-east1-c]
[14] Do not set default zone
Please enter your numeric choice: 9
Your project default compute zone has been set to [us-central1-f].
You can change it by running [gcloud config set compute/zone NAME].
Your project default compute region has been set to [us-central1].
You can change it by running [gcloud config set compute/region NAME].
Do you want to use Google's source hosting (see
"https://cloud.google.com/source-repositories/docs/") (Y/n)? n
gcloud has now been configured!
You can use [gcloud config] to change more gcloud settings.
Your active configuration is: [default]
[app]
suppress_change_warning = true
[compute]
region = us-central1
zone = us-central1-f
[core]
account = timothy.xxxx#gmail.com
disable_usage_reporting = False
project = xxx-gae-01
Timothys-MBP:2-hello-world tgwright$ gcloud auth list
Credentialed accounts:
- timothy.xxx#gmail.com (active)
To set the active account, run:
$ gcloud config set account ``ACCOUNT''
Timothys-MBP:2-hello-world tgwright$ gcloud config list
Your active configuration is: [default]
[app]
suppress_change_warning = true
[compute]
region = us-central1
zone = us-central1-f
[core]
account = timothy.xxxx#gmail.com
disable_usage_reporting = False
project = xxx-gae-01
Timothys-MBP:2-hello-world tgwright$ gcloud preview app deploy --verbosity debug
DEBUG: Running gcloud.preview.app.deploy with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.preview.app.deploy', usage=None, description="*(BETA)* This command is used to deploy both code and configuration to the App Engine\nserver. As an input it takes one or more ``DEPLOYABLES'' that should be\nuploaded. A ``DEPLOYABLE'' can be a module's .yaml file or a configuration's\n.yaml file.", version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), account=None, authority_selector=None, authorization_token_file=None, bucket=None, cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x10e936590>>, command_path=['gcloud', 'preview', 'app', 'deploy'], configuration=None, credential_file_override=None, deployables=[], docker_build=None, document=None, force=False, format=None, h=None, help=None, http_timeout=None, ignore_bad_certs=False, image_url=None, log_http=None, project=None, promote=None, quiet=None, repo_info_file=None, server=None, stop_previous_version=None, trace_email=None, trace_log=False, trace_token=None, user_output_enabled=None, verbosity='debug', version=None).
DEBUG: API endpoint: [https://appengine.googleapis.com/], API version: [v1beta4]
You are about to deploy the following modules:
- xxx-gae-01/default (from [/Users/tgwright/Google Drive/Sites/2-hello-world/app.yaml])
Deployed URL: [https://xxx-gae-01.appspot.com]
Do you want to continue (Y/n)? y
Beginning deployment...
DEBUG: Host: appengine.google.com
DEBUG: _Authenticate configuring auth; needs_auth=False
DEBUG: Sending request to https://appengine.google.com/api/vms/prepare?app_id=ebt-gae-01 headers={'X-appcfg-api-version': '1', 'content-length': '0', 'Content-Type': 'application/octet-stream'} body=
INFO: Attempting refresh to obtain initial access_token
INFO: Refreshing access_token
If this is your first deployment, this may take a while...\DEBUG: Got response: {bucket: vm-containers.xxx-gae-01.appspot.com, path: /containers}
If this is your first deployment, this may take a while...done.
INFO: Not checking for [go] because runtime is [ruby]

Rubymotion Enterprise Release

How does one release to a staging environment or create a release for Enterprise/Ad Hoc distribution?
This is different from an AppStore release and requires a different provisioning profile, and optionally a different bundle id.
You'll need to add a conditional in your Rakefile and make sure that you have all the correct certificates and provisioning profiles for each type of build you want.
app.release do
if ENV['staging'] == "true"
app.codesign_certificate = "iPhone Distribution: Your Company's Enterprise Certificate"
app.provisioning_profile = "distribution/Enterprise.mobileprovision"
app.identifier = "com.yourcompany.appnameenterprise"
else
app.codesign_certificate = "iPhone Distribution: Your Company's App Store Release Certificate"
app.provisioning_profile = "distribution/AppStore.mobileprovision"
app.identifier = "com.yourcompany.appname"
end
end
To set up the staging ENV variable I have another rake task that sets it:
task :set_staging do
ENV['staging'] = "true"
end
Then to actually release:
desc "Release Enterprise build"
task :enterprise_release => [
:set_staging,
"archive:distribution",
]

Resources