Showing posts with label Jenkins. Show all posts
Showing posts with label Jenkins. Show all posts

Tuesday, October 29, 2013

Building iOS apps for Simulator with Xcode 5 with command line

Things a little changed since Xcode 4

If you want to build your project for simulator 
and want to do it with the latest and the greatest version of Xcode - version 5.x
and want to do it with command line utility xcodebuild, 
because you need this for Continuous Integration or someth, 
then: 

1. In your Build Scheme for Simulator in project's "Build Settings" in section "Code Signing" set:
  • "Don't Code Sign" for "Code Signing Identity"
  • "None" for "Provisioning Profile"
2. In command line use iphonesimulator7.0 as desired SDK
(even if you have downloaded SDK 6.1, it won't help. not without other voodoo dark magic)

/usr/bin/xcodebuild -verbose \
  -project MyCoolProject/MyCoolProject.xcodeproj \
  -scheme MyCoolProjectSimulator \
  -configuration Debug \
  -arch i386 \
  -sdk iphonesimulator7.0 \
  TARGETED_DEVICE_FAMILY=2 \
  clean build

where TARGETED_DEVICE_FAMILY is iPhone (1) or iPad (2)


Tuesday, September 24, 2013

A strange way to populate SSH keys from Jenkins to Jenkins Slave node

Using sshpass tool as a workaround for ssh interactive password prompt. :-)


mkdir tmpz
cd tmpz
tar -zxvf sshpass.tgz

cd sshpass-1.05
./configure
make
./sshpass -p "hudson"  ssh-copy-id -i ~/.ssh/id_rsa.pub hudson@10.116.65.165

Monday, September 2, 2013

Jenkins + Gradle + Proxy

To make Gradle use HTTP Proxy when executing on Jenkins with Gradle plugin installed,
one has to use Environment variable JAVA_OPTS to pass proxy servers to Gradle.

For example:

JAVA_OPTS=-Dhttps.proxyHost=192.168.1.1 -Dhttps.proxyPort=3128 -Dhttp.proxyHost=192.168.1.1 -Dhttp.proxyPort=3128

Also one could use gradle.properties or configure gradle build files to use proxies.
Though JAVA_OPTS is a more universal way as one could have multy node configuration of Jenkins. For example: master does not use proxy, and some slave node is located behind proxy, so setting JAVA_OPTS in node environment will do the job.

Friday, August 30, 2013

HomeBrew: Installing right software to Mac OS X

Mac OS X can behave polite - one can install required software using HomeBrew http://brew.sh/

Homebrew installs the stuff you need that Apple didn't.
brew install wget

For example, let's prepare our Mac OS X for Jenkins CI

brew install  -v --devel --build-from-source --fresh wget automake autoconf libtool libzip pkg-config libimobiledevice



Start process, get PID of just started process, and terminate the process by PID later

Ok, let's say we have a usecase - a job on Jenkins CI that needs to start a background process, remember PID of the process, pass the PID to some later cleanup. And we need something that will work on Linux and on Mac OS X (yes, even this OS can behave polite).

So 1st, let's start a process and remember it's PID. This is done via $! shell environment variable. The $! variable will have PID of latest started process. So here is an example:

nohup tail -f /var/log/syslog > /tmp/$BUILD_TAG.log & export LOGGER_PID=$! 
# $BUILD_TAG - is an environment variable provided by Jenkins CI, it has unique job execution identifier

2nd, let's remember the PID

echo -e "LOGGER_PID=$LOGGER_PID" > /tmp/$BUILD_TAG

3rd, let's use the PID and send SIGTERM to the process if it is still alive. We'll wrap it to a shell script.

#!/bin/bash
. /tmp/$BUILD_TAG  # read to LOGGER_PID env variable

kill_proc(){

  local pid_alive=`ps ax| awk '{print $1}' | grep -e "^$LOGGER_PID$" >>/dev/null; echo $?`;
   # ps ax| awk '{print $1}' - will print to stdout PIDs without surrounding spaces
   # grep -e "^$LOGGER_PID$" >>/dev/null; - will search for the PID, ^ and $ are important, just in case our PID is a substring of some other PID on system
   # echo $? - will echo exit code of last command
  if [ $pid_alive -eq 0 ]; then 
    kill $LOGGER_PID; # sending  SIGTERM to the process
    sleep 10;
  else
    echo "Proc with PID $LOGGER_PID already terminated" 
  fi;  
}

kill_proc;