Thursday, September 24, 2015

Jenkins on Mac...


Hi Guys,

Now a days Continuous Integration [CI] has become an eternal part of software development.
This allows user to :
a) Integrate and share their code in a repository
b) Make error checks in builds
c) Automatic generation of builds [includes packaging and signing]
d) Generating artifacts

To enjoy the prospects of CI we are going to use a tool named JENKINS.
Jenkins is a server based system which provide CI services

SCM tools with which Jenkins can be integrated with are:
Git, Mercurial, SVN, CVS etc..


Lets first start with configuring Jenkins on MAC machine.
You can use OSX installer with nice GUI or go ahead with Homebrew

I will prefer to go ahead with Homebrew so here we go

1) Open Terminal and go ahead with below mentioned commands

********** HOMEBREW SETUP **********



swati:~ admin$ 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin14/rbconfig.rb:213: warning: Insecure world writable dir /usr in PATH, mode 040777

==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> Downloading and installing Homebrew...
remote: Counting objects: 3744, done.
remote: Compressing objects: 100% (3579/3579), done.
remote: Total 3744 (delta 40), reused 567 (delta 28), pack-reused 0
Receiving objects: 100% (3744/3744), 3.14 MiB | 240.00 KiB/s, done.
Resolving deltas: 100% (40/40), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at 98c28ae gst-plugins-bad: can optionally use srtp

==> Installation successful!

==> Next steps
Run `brew help` to get started

********** JENKINS DOWNLOAD **********


swati:~ admin$ brew install jenkins

After installing Jenkins Homebrew provides you some useful tips as well

==> Downloading https://homebrew.bintray.com/bottles/jenkins-1.629.yosemite.bottle.tar.gz
######################################################################## 100.0%

==> Pouring jenkins-1.629.yosemite.bottle.tar.gz
==> Caveats
Note: When using launchctl the port will be 8080.

To have launchd start jenkins at login:
  ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents

Then to load jenkins now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

Or, if you don't want/need launchctl, you can just run:
  jenkins

==> Summary
🍺  /usr/local/Cellar/jenkins/1.629: 6 files, 61M

********** UPDATE JAVA **********


swati:~ admin$ jenkins @ dev > sudo touch /Library/LaunchDaemons/org.jenkins-ci.plist

Jenkins requires Java7 or later, but you are running 1.6.0_65-b14-466.1-11M4716 from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
java.lang.UnsupportedClassVersionError: 50.0
at Main.main(Main.java:90)

Remember to update your Java to latest to enjoy best features

********** LAUNCH DAEMONS **********


swati:~ admin$ sudo launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist
Password:
/Library/LaunchDaemons/org.jenkins-ci.plist: Path had bad ownership/permissions

swati:~ admin$ sudo chmod 600 /Library/LaunchDaemons/org.jenkins-ci.plist
swati:~ admin$ sudo chown root /Library/LaunchDaemons/org.jenkins-ci.plist
swati:~ admin$ sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

********** org.jenkins.plist **********


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>Jenkins</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/bin/java</string>
            <string>-jar</string>
            <string>/usr/local/Cellar/jenkins/1.414/lib/jenkins.war</string>
        </array>
        <key>OnDemand</key>
        <false/>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>jenkins</string>
    </dict>
</plist>

If user has a different name remember to add that in plist else it will run via System root


After all this you can reboot your MAC or type below mentioned command in browser
http://localhost:8080

yippieeee.... see how it looks



Now you are ready to go ahead...
Create your jobs , download plugins, integrate SCM, automate builds & Enjoy..

Hope you enjoyed the first step.
Next step will be posted soon
:)













3 comments: