Compile time error for plist entry - ios

I need to generate a build error if a plist entry is not present. How can I approach it ? Any information on this would helpful.

You need to write a script that checks the .plist file as part of the build.
See Running a Script While Building a Product.
If the script terminates with a non-zero exit code (i.e. exit 1) then the build will fail.

MAC OS X's has already a built in tool for your issue :- /usr/libexec/PlistBuddy
For success, it returns exit code is 0
For failure, it returns exit code is nonzero
For regular output is sent to stdout, error messages is sent to stderr

Related

For Kubernetes pods how to find cause of exit code 2

I have pods that are of kind Cronjob running in parallel. They complete task and run again after fixed interval of 20 minutes as per cron expression. I noticed that some pods are restarting 2-3 times before completing task.
I checked details in kubectl describe pod command and found that pod exit code 2 when it restart due to some error:
Last State: Terminated
Reason: Error
Exit Code: 2
I searched about exit code 2 and found that it is misuse of a shell builtin commands. How I can find which shell builtin is misused. How to debug cause of exit code 2.
Thanks in advance.
An exit code of 2 indicates either that the application chose to return that error code, or (by convention) there was a misuse of a shell built-in. Check your pod’s command specification to ensure that the command is correct. If you think it is correct, try running the image locally with a shell and run the command directly.
Refer to this link for more information.
You can get logs with
kubectl logs my-pod
Post output here if you can't fix it.

Codeship marks the test as "failed" even when there is no error

I have some rails-cucumber tests, all looks fine but CS says the test suite failed:
I didn't set "--strict" in the command line.
You'll want to investigate why it is that your process might be returning a non-zero exit code. The recommendation here is to hop into an ssh debug for your build and verify that each step is returning a zero exit code:
echo $?

IOS upload symbol files for crash reporting fail

/Users/appledev018/LarsonApp/Pods/FirebaseCrash/upload-sym-util.bash:335: error: curl exited with non-zero status 35.
hello
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
I follow the guide to set up firebase crash reporting and when I run my project get above error
and following is my script
echo "### hello world"
GOOGLE_APP_ID=1:688585241582:ios:0203552cad37c112
echo "### hello google"
"${PODS_ROOT}"/FirebaseCrash/upload-sym "${PROJECT_DIR}/ServiceAccount.json"
echo "### hello"
Enable "Run Script only when install" in build phases. Then it'll run as expected. This will avoid to upload the script each time when run the system.
Please refer attached screen shot.
If you have bitcode enabled, you can use this script to automate the process and not worry about the rest.
Follow these steps carefully
Add your unzipped dsym folder to your project's main directory
Add this script to the dsym folder
Open terminal
cd into the dsym folder in the project's main directory
Run this python script i.e 'python batch_upload_files.py'
https://github.com/hanijazzar/Contributions/blob/master/batch_upload_files.py
Maybe I am a bit late, but here is a solution.
The problem is that curl can not verify the SSL certificate on the remote server and therefore blocks the transfer because it seems to be insecure.
You have 2 options:
1) Add -k as an option to the curl call. (This means to edit the script in the pod.)
2) Allow insecure SSL connections generally. (This disables certificate chain checking but leaves other validation enabled.)
$ echo insecure >> ~/.curlrc

Parse Crash Reporting - Script Does not End

I just enabled ParseCrashReporting in my app, and now when I build the app, Xcode stays on "Running 2 of 2 custom shell scripts" (i have another simple script for HockeyApp integration, placing it before that does not change anything).
My script is below:
export PATH=/usr/local/bin:$PATH
cd ~/OneDrive/AppName
parse symbols AppName -p "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
My AppName folder is also where I started my parse cloud repo, it contains the folders cloud, config and public. I tried changing the path to AppName/cloud but no change.
Xcode stays running that script for a long time...i've waited 10 minutes for it before and it doesn't continue beyond that. Once I stop the build, I get an error: Shell script invocation error:
Uploading iOS symbol files...
Command /bin/sh failed with exit code 1
I assume the error just shows because I cancel the task. Why would this be sticking like so? I have looked at several questions on parse crash reporting and have not seen any similar issues.
Just use the following script instead, I just tested it and it works:
echo "Parse Crash Reporting"
export PATH=/usr/local/bin:$PATH
CLOUD_CODE_DIR=${PROJECT_DIR}/helloKittyAdventureTimeCloudCodeFolder
if [ -d ${CLOUD_CODE_DIR} ]; then
cd ${CLOUD_CODE_DIR}
parse symbols YOUR_PARSE_APP_NAME --path="${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
echo "Finished uploading symbol"
else
echo "Unable to upload symbols"
fi
IMPORTANT:
The following line needs to be changed based on your folder name, that's it, keep everything else the same:
CLOUD_CODE_DIR=${PROJECT_DIR}/helloKittyAdventureTimeCloudCodeFolder <===this should be the
name or your own folder!!, so, if your folder is named theAdventuresOfCaptainCookCloudCode,
then you would type this:
CLOUD_CODE_DIR=${PROJECT_DIR}/theAdventuresOfCaptainCookCloudCode
Also, one more thing to note, you don't need the echos and such if your run this as a Run Script in Xcode, but you don't have to take them out either, you can just run it like this and you won't have a build error.
One more thing, make sure to change YOUR_PARSE_APP_NAME to the name or your app, sorry about that, this also needs to be changed

Jenkins post build task script aborting when result of `{cmd}` is empty in script

I got strange behavior of Jenkins post build task script.
its purpose is showing build error in slack like following.
EDIT: our Jenkins running on Mac OSX Yosemite (10.10.4) and using Unity3d as build tool.
SLACK_BOT_PATH=$WORKSPACE/tools/bot.rb
SLACK_BOT_NAME="cortana"
SLACK_BOT_TOKEN=`cat $WORKSPACE/../../sendchat_token`
ERRORS=`tail -5000 ~/Library/Logs/Unity/Editor${BUILD_NUMBER}.log | grep ": error"`
ruby $SLACK_BOT_PATH $SLACK_BOT_NAME $SLACK_BOT_TOKEN "build fails : $ERRORS"
and strange behavior is, it aborted on the ERRORS= line when ERRORS has no contents (empty string). Jenkins console output is like following.
[workspace] $ /bin/sh -xe /var/folders/j3/8x825bdn2l9dm497yjs2144c0000gn/T/hudson7348609981772923445.sh
+ SLACK_BOT_PATH=*snip*
+ SLACK_BOT_NAME=cortana
++ cat *snip*/../../sendchat_token
+ SLACK_BOT_TOKEN=*snip*
++ tail -5000 ~/Library/Logs/Unity/Editor1710.log
++ grep ': error'
+ ERRORS=
POST BUILD TASK : FAILURE
after I change grep filter so that ERRORS has some contents, the post build script runs correctly again.
I want to report some general error message (eg. build fails) when no actual ERRORS found in logs. but also report detail error message when its available.
of course it is easy that inserting some line to send general message before grep error log so that every time such a general message sent to slack, but I want know the reason why empty ERRORS terminate entire script.
does anyone encounter same issue? if so, finally you know the cause of problem? thanks.
To be precise Jenkins will terminate your build when ERRORS is empty in you code because when there is no output from the grep command, your shell errorlevel will be set to 1 automatically , therefore it terminates your build with error ERRORS= , you can debug the same by printing errorlevel value. echo $ERRORLEVEL [linux] or echo %ERRORLEVEL% [windows]. Error 0 stand for success and other error codes stands for failure. if you want your post build script to be executed ignoring even if grep output is empty , then set errorlevel value in post build step of jenkins build.
ERRORLEVEL=0
Try the above and see if that helps
As #prudviraj explained, the issue is that your grep command returns without finding anything, and therefore returns with exit code 1.
Read detailed answer here: Jenkins Build Script exits after Google Test execution
In short: your script is launched with /bin/sh -xe, the -e means "fail immediately on any error", and your grep "errors out" when nothing is found.
The quick fix is to put set +e before the command. But the better way is proper error handling, as explained in the other answer I've linked.

Resources