Fastlane Gymfile - pilot returns "No ipa or pkg file given" after gym - devops

Setup
I'm running Fastlane over CI (Gitlab) and having a common flow:
match(type: ...)
gym(scheme: ..., export_method: ...)
pilot
Each line is actually run in a different job and most environment variables are stored in dotenv files, Appfile, and Gymfile. In particular, I have set the output_directory in the Gymfile. Also, I know that the .ipa is created because I've checked the output_directory and it's there.
Issue
It seems that the output directory variable is not retained and passed to the downstream job that executes the distribution via pilot. My guess is that the SharedValue set in the Gymfile has to be saved and made available to the job running pilot.
Question
I know I could simply pass the output path to pilot via argument, but I'd prefer to keep configuration variables in external files, such as a Gymfile. So my question is the following:
"Is there a way to make pilot aware of the variables set in the Gymfile? Or do I need to create some sort of Pilotfile (?) and set again the output_directory".

Related

Xcode build environment variable for scheme that is running

I've been trying to find a way to access the scheme name from a Run Script build phase. I'm writing a CLI command that updates a user's Xcode project so I don't have the luxury of tinkering with the Xcode user interface. I have been using Cocoapod's Xcodeproj dependency to update the build settings.
The first port of call is Xcode's build settings environment variables which do not contain the scheme. See here: https://developer.apple.com/documentation/xcode/build-settings-reference
I thought I would be able to do it programmatically via Xcodeproj dependency, but it appears the environment variables it sets are for the run-time application, not the build settings environment variables. See here: https://www.rubydoc.info/gems/xcodeproj/Xcodeproj/XCScheme/EnvironmentVariables
Apple's documentation on schemes makes no suggestion for this predicament:
https://developer.apple.com/documentation/xcode/customizing-the-build-schemes-for-a-project
QUESTION:
I was wondering if anyone had any suggestions for obtaining the scheme name that is running from a Run Script build phase? Some setting I could apply programmatically using Xcodeproj or another tool to configure the project that could pull the scheme name as a value at build time?
I don't want to hardcode the value into the script as this would require generating multiple scripts in the build phases for each scheme.
A scheme isn't really a "thing"; it is merely a unification of several other aspects of the build operation. The particular aspect you probably want is the configuration, which is available as the CONFIGURATION build environment variable. In a bash script, for example, you can include a line such as
if [ $CONFIGURATION = "MyWonderfulConfiguration" ]; then
You can create configurations in the Project editor, and you can tie each scheme to its own configuration in the Scheme editor.
Configuration:
Scheme:
Environment variables:

How do I get the path to SPM when I perform a archive?

I am now trying to use WireGuardKit, where it asks to create an "External Build System" and fill in the Directory with ${BUILD_DIR}/... /... /SourcePackages/checkouts/wireguard/Sources/WireGuardKitGo (this path has been modified and I guarantee that this path will allow me to pass the compilation).
However, when I execute archive, Xcode reports an error unable to spawn process '/usr/bin/make' (No such file or directory).
I suspect that $(BUILD_DIR) doesn't have a value when the compilation is executed, or I can't use this environment variable at this stage. Because when I don't use relative paths and use absolute paths to assign values to Directory, the project is able to archive successfully.
So my question is, when I execute the archive, how do I get the path of the package I inherited using SPM? Or can I use $(BUILD_DIR) environment variable when I execute archive? Why is it different from when compiling?
UPDATE:
I learned that $(BUILD_DIR) uses $() within it and when I try to use $() directly, it still reports an error, I also tried variables like $(BUILD_PATH), $(BUILD_ROOT), $(BUILT_PRODUCTS_DIR), but none of them work.
So could it be a problem with $(), an environment variable that has no value when the archive is executed?
How do I get the SPM directory when executing the archive?
I was able to solve this issue with an alternative configuration for External Build System
Here is a tutorial (see section "Manual Xcode steps")
The main idea is to use build_wireguard_go_bridge.sh script in your External Build System configuration:
Build Tool: $(PROJECT_DIR)/Scripts/build_wireguard_go_bridge.sh
Arguments: $(ACTION)
Directory: <empty>

Build Task to Conditionally Copy Files to a Directory

I am completely new to vNext Tasks & need some help. I have some Custom Configuration values defined in my Solutions, as follows:
DEV
DEV.HA (HA stands for High Availability)
QA
QA.HA
UAT
UAT.HA
PROD
PROD.HA
I have Service Account certificates in a set of folders separated by-environment. These need to be copied into a KEYS folder to replace the default files there.
FOR INSTANCE:
DEV & DEV.HA would get from one source-folder
QA & QA.HA would get from a different source-folder
...and so on.
How do you do conditional copying in vNext?
Which vNext task is best for that?
Either stick the "variable part" in a variable. This would be possible if you have naming logic that allows you to do configuration by convention.
Or put the logic in a powershell script or shell script and run that to set the values of the variables. There are special logging commands you can use to set the value of a variable from your script:
write-host ##vso[task.setvariable variable=YourVariableName;]QA
Then use the variable either in the standard Copy Files task or stick the copy files logic in Powershell as well.

Jenkins job for remote deployment - multiple environments

I'm trying to create a generic Jenkins job for deploying different projects from different GIT repos and branches to different application servers (in any combination).
I have 2 string build parameters for the repo and for the branch, and a small shell script in a pre-build step which based on the build params creates a deploy.properties file with properties URL and PROFILE.
Another pre-build step is the Inject environment variables which uses the deploy.properties file previously created.
I'm to use the URL property in the Jenkins Deploy Plugin in the following way: Tomcat URL field - $URL.
Also, in the build section, I'm using the PROFILE property: clean install -P$PROFILE .
The problem is that the placeholders or not replaced by the values I've set in the shell script. Not that is I do another post-build action and I'm echoing the same placeholders, the values are replaced and it seems to work. Other check I've done is the Environment Variables section from a given Build and the variable values are there, so the injection works.
Any ideas?
Try the below and make sure you don't have the cmd in single quotes or anything.
clean install -P${PROFILE}

How do you access Xcode environment (and build) variables from an external script?

I am writing a script to automate my iOS building. It will be run outside of Xcode, either via Terminal or from build automating software. Is there any way to have access to Xcode environment variables in my script, so I don't have to try and derive them myself?
For example, can I get access to PROJECT_DIR instead of assuming I'm in the current directory and running pwd?
I am currently hardcoding the product names for my different build configurations. (I'm also hard coding the build configs, but I could parse them them from xcodebuild -list.) Is there a way to get the app if you know the build config name?
(I saw this related question but it doesn't have an answer for me.)
The Xcode environment variables are only defined for child processes of the xcodebuildcommand-line tool.
One solution I used is to have a very simple script as part of my build process (Project->New Build Phase->Add Run Script Build Phase). All this script does is export the necessary variables and call a script in my path somewhere.
That script could be generated by your build script before calling xcodebuild and voilĂ ! you have an external script that has access to Xcode build variables.

Resources