How to automatically confirm all fastlane commands with "Yes" - xcode

I want to execute fastlane command to update project signing.
fastlane run update_project_codesigning path:"PROJECT.xcodeproj"
For the first time it always asks for confirmation "Yes" or "No" to update xcode xcode format:
[18:50:33]: Updating the Automatic Codesigning flag to disabled for the given project '/Users/user/.jenkins/workspace/PROJECT-IOS/platforms/ios/PROJECT.xcodeproj/project.pbxproj'
[18:50:33]: Seems to be a very old project file format
[18:50:33]: PLEASE BACKUP ALL FILES before doing this.
Proceed with upgrade to xcode8 format? (y/n)
In terminal I can do
yes | fastlane run update_project_codesigning path:"PROJECT.xcodeproj"
and it works.
But on Jenkins it doesn't work. As far as I understood, Jenkins doesn't support interactive commands.
How can I automatically set "YES" confirmation for all fastlane commands?

I found out how to automatically confirm changing the xcode format.
Just set the FL_PROJECT_SIGNING_FORCE_UPGRADE environment variable to 1 or true.
I did:
export FL_PROJECT_SIGNING_FORCE_UPGRADE=1
fastlane run update_project_codesigning path:"PROJECT.xcodeproj"
and it works

Related

Gradle init isn't interactive

I am using gradle through command line for the first time. I am running the latest version of Ubuntu. My professor's instructions indicate that upon typing "gradle init" I should be prompted to say what type of project it is as well as the language, etc. Mine simply skips all of that and says "build successful" afterwards, my professors' file ends up with the proper directory structure and mine only has the basic root folders. From the quick searches I've done, I see that there is a difference between interactive and non-interactive responses, but I can't find anything regarding how to make it interactive.
My issue was I installed gradle with sudo apt install gradle which installs a very old version. Instead you can install sdk and then run sdk install gradle
If it says something along the lines of:
> Task :init SKIPPED
The build file 'build.gradle' already exists. Skipping build initialization.
BUILD SUCCESSFUL in 5s
Then it means you already have a Gradle build structure present. In order to initialize a new one, the directory you run it in must be empty.
I had this problem, too. Seems to be a bug.
You can tell gradle non-interactively what type to create, for example:
gradle init --type java-library
Other build types

Change Fastlane execution folder while inside a lane

We have a flow where we execute a custom script which copies the project on the desktop before it is signed and submitted.
Now we want to use Fastlane and we were thinking to do the following:
We start the fastlane build process
We execute the custom sh script
We do all the fastlane magic
And I am thinking the following - since my sh script is copying the project on the desktop, how can I continue the fastlane script execution from the copied folder and not the original (source) folder?
Should we start fastlane from our custom script instead?
I don't think fastlane is designed to change its working directory while running. It sets up a ton of environment variables when running and if any of those point to the old location you might be in trouble.
Make two fastlane lanes, one for the old location, one for the new. Then your script looks like this
cd old-location
fastlane old_lane
cp -r old-location new-location
cd new-location
fastlane new_lane
Fastlane is great... for certain tasks. Personally I've had a lot more success treating it as a convenience wrapper for a few specific functions rather than an all-in-one solution, so don't be afraid to break out of it. For example, we only use fastlane for submitting our app, not for building and testing (read more).

Xcode server bot error "Trigger exited with non zero status 2"

Hey I wanna set up a Xcode server, in order to work properly I need to get the extension "Siren" to get installed before the bot runs and tests the Xcode project.
The problems here is that every time I integrate the bot to test my app it resets my installed Carthage extensions...
I think I need a pre integration script who installs the missing extensions into the bot when it starts.
At the moment I wrote as pre integration script (called "Install dependencies"):
#!/bin/sh
cd /Users/catrobat/Library/Caches/XCSBuilder/Bots/9194b282ad9904370a8be66eb400f02d/Source/Catty
make init
The folder dictionary is where my bot gets created and make init is the command in order to get home-brew to install "Siren" and more in the make file.
But it doesn't work and I get the error "Trigger exited with non-zero status 2"
Does anyone know how to fix this?
Xcode Server exposes XCS_PRIMARY_REPO_DIR which is just what you need:
#!/usr/bin/env bash
set -e
pushd "${XCS_PRIMARY_REPO_DIR}"
make init

Fastlane command not found in XCode bots post build trigger

Here's my script
echo "===================="
echo "MAKE ENTERPRISE IPA"
echo "===================="
pwd
cd "${XCS_PRIMARY_REPO_DIR}/"
pwd
fastlane enterprise
This is what's in the logs
====================
MAKE ENTERPRISE IPA
====================
/Users/XcodeServer/Library/Caches/XCSBuilder/Bots/1fc5d5c4b44f01807859f14cc303b56c/Source
/Users/XcodeServer/Library/Caches/XCSBuilder/Bots/1fc5d5c4b44f01807859f14cc303b56c/Source/ProjectName
/var/folders/rc/28t61gwn3c1bcsn1b360d0h40000gp/T/F389538F-77F0-481A-A413-456C809755D1-22343-000364DDDB596983: line 10: fastlane: command not found
If I march directly to the directory on the build server and go to XCS_PRIMARY_REPO_DIR and type in fastlane enterprise everything works fine. I don't know why it's looking in var/folders for fastlane.
Any help would be greatly appreciated thank you.
I added usr/local/bin to the path. I added the following line before I call fastlane. If anyone knows of a better place to put it. I'm all ears.
export PATH=/usr/local/bin:$PATH
Follow this steps:
Navigate inside the repo. e.g.cd TemplateProject.
Add fastlane command.(Since xcode server can't find the Fastlane command you need to specify path)
To know the path navigate to your project folder from terminal and execute command:
which fastlane
Result will look as:
/Users/yourcomputername/.fastlane/bin/fastlane beta
Now use this to create a post Script command as attached in the image
This now makes xcode server find your fastlane.

Using scripts in PackageMaker (Mac OS X)

I'm trying to build an install package on Mac for my application(s) (there are two .app-s). One of them is a GUI and the other is an agent (service). The install package must run a script (that's the only way I know it can be done) at the end of the installation, so that the agent would be installed as an agent. There is also a .plist file that is installed in /Library/LaunchAgents, but that's what PackageMaker does automatically (ie without the need of a script).
The problem is that... I can't make the script run. I get "Installation failed" at the end.
I don't know what the problem is. Can somebody please help?
A few more details:
I'm trying to do this at the postflight step (after the installation is done). just a guess... do I need to call my file with the same name (eg. postflight)?
I suppose this is the correct directory and path I have set. After dozens of attempts, in the last one I set as "relative path" the path where the PackageMaker document is (in the same folder I have the script). Is there something important I should know about paths that might cause the problem? (the fact is, however, that the build is successful)
do I have to write something specific to allow the script to be executed? I've got the following script:
MyInstall.sh
with the following contents (without quotes):
"#!/bin/sh
sudo launchctl load /Library/LaunchAgents/com.MyCompany.MyService.plist"
(note that com.Mycompany.MyService.plist is already there - it puts it there on install).
P.S. In some of my attempts to make it work, PackageMaker crushed.
Can anybody PLEASE help?
You can look at the installation log.
When the Installer application is running, go to the Window menu and select Installation Log. This will open a separate log window. In this window, select Display All from the combo box. You will be able to see why your script is failing.
I had such experience myself. And here's what i've found out.
In order for installation to succeed your sript must explicitly return 0(i.e. 'success').
If result of commands in your script is not 0 and you aren't calling
exit 0
as last script sentense, your install will tell you it failed.
If you don't use script's return value and you are sure scrpit works correct - just add 'exit 0' at the last line of script.

Resources