Abstract2Paradox

Gautam's Beta.Log

Jenkins Build Server With Github Authentication

| Comments

I was recently setting up a Jenkins Server, here is a simple tutorial on how to do it.

The agenda

  • Jenkins Build Server for building a gradle project
  • Github Authentication
  • Run Builds from Github private repository
  • Build Pull requests

Step 0:

Get a Ubuntu 12.04 Server with at-least 1 GB RAM and a good processor. If you are building this on EC2 a M1 Small Instance will suffice.

Step 1: Setup Ubuntu

  • Install openjdk on the server by typing sudo apt-get install openjdk-7-jdk on the terminal.
  • Install git using sudo apt-get install git

Step 2: Install jenkins

Install jenkins by following the tutorial on jenkins-ci.org

  • wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
  • Add the following line to /etc/apt/sources.list
    • deb http://pkg.jenkins-ci.org/debian binary/
  • sudo apt-get update
  • sudo apt-get install jenkins

Step 3: Start Jenkins

  • Start the Jenkins server by typing sudo service jenkins start,
  • Make sure its running by typing sudo service jenkins status to get a result likeJenkins Continuous Integration Server is running with the pid xxxx.
  • And finally visit the http://<sever-ip>:8000/ to get a page like

Jenkins dashboard

Step 4 : Install plugins

Here is a list of plugins and version that I have installed at the time of writing this tutorial

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Jenkins Mailer Plugin 1.4
LDAP Plugin 1.2
External Monitor Job Type Plugin 1.1
pam-auth 1.0
Ant Plugin 1.2
Javadoc Plugin 1.1
Credentials Plugin 1.3.1
SSH Credentials Plugin 0.2
Maven Integration plugin 1.506
SSH Agent Plugin 1.0
Jenkins SSH Slaves plugin 0.22
Jenkins GIT client plugin 1.0.4
Jenkins GIT plugin 1.3.0
Git Parameter Plug-In 0.2
GitHub API Plugin 1.34
GitHub plugin 1.5
Github Pull Request Builder 1.5.1
Performance plugin 1.8
Jenkins CVS Plug-in 2.8
Jenkins Subversion Plug-in 1.45
Jenkins Translation Assistance plugin 1.10
Github Authentication plugin 0.13.1
Jenkins Gradle plugin 1.21

These plugins can be installed from Manage Plugins page

Plugin Management

Step 5 : Configure Jenkins

  • Open the configuration page

Jenkins Configuration

  • Set jdk installation to /usr/lib/jvm/java-7-openjdk-amd64

Jdk installation Jdk installation

  • Assuming you have installed git via the package manager, you can leave the configuration as it is.

Git installation

  • Assuming the gradle plugin has been installed, Configure the gradle installation

Gradle installation Gradle configuration

  • Set the url of the jenkins server

  • Configure the git installation of the git client

  • Setup Email Notifications if you need it

  • Setup the github hook and the pull request builder, Refer Step 8 for the credentials of the pull request builder.

The admin list is a list of admin usernames in github separated by white space.

Step 6: Setup Security with Github Login

  • To use github login, Register an application with github. Make sure the callback url is http://<server-ip>/securityRealm/finishLogin

  • Once the application is registered copy the cliend Id and client Credentials

  • And add them to the oauth plugin

  • Set the admin github users and organisations

Step 7: Setup ssh key for jenkins

  • Ssh into the server and swtich user to jenkins using the command sudo su jenkins
  • Navigate to the home directory and create a directory called .ssh using mkdir .ssh
  • use the command ssh-keygen -t rsa to generate a new ssh key , do not set any password for the key
  • restart the jenkins server using sudo service jenkins restart

Step 8: Builds user

  • Create a new builds user in github
  • Upload the public key generated in the previous step to github
  • Grant permission for the builds user to access your private repository
  • Enter the credentials of the build user for the pull request builder in Step 5.
  • Refer help.github.com for more information on this step

Step 9: Create a new Job

  • Create a new job

  • Setup the vcs for the job as git, Enter the repository url from which to clone, like git@github.com:username/example.git

  • Set the name of the repository ass origin

  • Specify the branch to build like origin/master
  • Set the repository browser as githubweb and specify the url of the Github project like http://github.com/user/project
  • Check the options Build when a change is pushed to GitHub and Github pull requests builder
  • Add a build step Invoke a gradle script
  • Add a new build post build action for sending an email.

Step 10:

Enjoy the power of Continuous Integration on you Github project with gradle builds.

Opinions on Good Programming Skills

| Comments

Its been about 9 weeks since I wrote my last post so I figured I would get back on the writing bandwagon. Since I wasn’t in the mood to figure out an Idea to write about (Not that I have before (I am trying to writing more and more like a novelist)), I thought I would just attach my opinion along with someone else’s work.

The first thing that I saw on was something that I found on hackerne.ws. Its an article written by Emma Mulqueeny for the telegraph. It can be found here.

Here is my $0.02 before I start wasting more of your (the un/fortunate) reader’s time. I have been programming since I was around 14 years old , I know its quite late by today’s standards. If there is one thing that I learnt in all these years, its that the most basic requirement for a programmer is the ability to learn without a teacher (I know this has been said a trillion times before , but didn’t I say this was my 2 cents and not yours !). Now lets get back to the article at hand and leave older times for newer times.

I agree with Emma’s point that the biggest hurdle that most adults who have never done any programming in their life, is getting over the expectation of someone to teach it to you. Generally programmers are the laziest people in the world, also a reason why some are so good, they are always DRY (inside joke), and have no to time(In reality patience) to sit someone down and spoon feed it. So unless you have had some school teacher feed it to you, it may not be an easy journey.

Then the next major turn off as Emma points out is MATH, The old myth that programmers have to Fields Medal winners in math still goes around. Take me for example, I sucked at school math which I just scrapped through, But I got A+ in Computer Science. Same story in College, I easily aced all the subjects that needed me to write code, those which needed mugging up (Don’t ask why a Computer Science major has to mug up stuff at College Level, Its still prevalent in many countries) were a bit of a struggle.

It is true that you do need to be good with Physics, Math and any other thing that needs to be done, But there are skills that are a bit more important than Math or Physics, which(Math) is not really that hard to pickup once you have self learning module installed. No commercial programmer is going to be writing code for some wild scientific experiment which requires Genius Level IQ ,most of the code required in those areas are written by the Mad Scientists themselves (Obviously !).

The real requirements are, the ability to break a problem into a million pieces when needed and then to put it back together to get the whole picture back, Then a programmer needs to be able to write clean code with multiple levels of abstraction, In the programming world the code you write is like your handwriting. Good programmers also need to be good managers, they need to be able to make some difficult decisions and trade-off.

My favourite example for a trade off that a programmer needs to decide about is whether bad code is worth that extra bit of performance or good maintainable code is better even if it is less performant.

Then there is this cult like status that many programmers attach to the tools of the trade , especially programming languages, This is something that needs a lot of maturity to get rid off.

Programming languages are after-all tools and the newest or the for that matter oldest or the most philosophically right tool may still not be right choice for a task. This final opinion, in my opinion does not come easily, some programmers never understand this.

After all tools are tools and it doesn’t matter which one was used, What matters is whether the problem was solved.

This might just be the most difficult to read post that I have written, So If you have reached till here, Thank you !!

As always comments are welcome .

.gitignore Creator

| Comments

I create a lot of git repositories, and manually creating .gitignore files for each is a pain, so I wrote this python script to do it for me.

Currently it depends on wget so is should work fine on Linux and Mac, To get it to work on windows try installing wget, or modify the code to download the files from python.

The Pun in Martin Odersky’s Scala Course

| Comments

I was watching Functional Programming Principles in Scala and in lecture Elements of Programming I noticed this nice pun.

C++

Martin talks about how the functional programming model can only be applied to expressions that do not have side effect and then to explain what side effects are he uses this term c++ which is essentially incrementing the value of c

The pun lies in choosing the name of the variable to be c when he could have chosen any other letter the alphabet.

C is the name of the programming language which is synonymous with imperative programming and C++ is its Object Oriented sibling.

There are ways to write Lambda Calculus and Functional programming in C++ but in my personal opinion it seems like an after thought, Just like how C++ was and will always be an after thought of adding Object Orientation to C.

AntLR AST to Code

| Comments

About a year back I learnt to write AntLR grammars by watching Scott Stanchfield’s video tutorial. The tutorial helped me in writing the grammar for a simple language, but sadly I was unable to take it further because after I had generated the Abstract Syntax Tree (AST) I had no clue how to take it further and generate code with it. Now the project lies dormant.

I recently came across this tutorial series by Bart Kiers titled Create your own scripting-like language with ANTLR and I am now confident that My language will come alive soon.

Remove Whitespace From All Filenames

| Comments

Here are some scripts to remove all spaces from filenames in the current directory

Bash
1
2
3
4
5
for i in * ; do 
    if [ $i != ${i//[[:space:]]} ] ; then
        mv $i ${i//[[:space:]]}
    fi
done
Python
1
2
3
4
5
import os
for f in os.listdir("."):
    r = f.replace(" ","")
    if( r != f):
        os.rename(f,r)

Another bash script by chepner

Bash
1
2
3
4
for old in *; do
    new="${old//[[:space:]]}"
    [[ $old = $new || -f $new ]] || mv "$old" "$new"
done

A ruby one-liner by glenn-jackman

Ruby
1
ruby -e 'Dir.foreach(".") {|f| f.count(" \t") > 0 and File.rename(f, f.delete(" \t"))}'

Related stackoverflow question.

Hacking JavaFX Scene Builder to Work on Linux

| Comments

JavaFX has been available on Linux for a while now, There is a tool for JavaFx called SceneBuilder which is a Visual Builder for JavaFx but sadly its is not available for Linux yet.

So when Stephen Chin came to chennai today for a session on JavaFx, and showed it working on a Mac I wanted to get it working on Linux.

How Does a Startup Out-recruit Google

| Comments

Here is something to think about, Imagine yourself as a fresh college graduate who gets job offers from an MNC and a startup , Which one do you choose ?

You should probably choose the start-up ! or should you ?

You decide for yourself. Meanwhile Read more →