Thursday, 24 December 2015

Automation: Create New Jenkins Job from template config xml file

Below Shell script helps to automatically create a new Jenkins Job from template config XML file.



Createjob.sh


#!/bin/bash
set +x

# To create a job
function create_job {
 mkdir $1
 cp template.xml $1
 mv ./$1/template.xml ./$1/config.xml
 echo Job $1 is created. 
}

#Modify TEMPLATE_SERVER, TEMPLATE_WORKSPACE keywords from template.xml are replaced from 
test.properties
function modify_job {
 . ./test.properties
 echo TEMPLATE_SERVER is replaced with $servername
 echo TEMPLATE_WORKSPACE is replaced with $workspace
 sed -i -- "s/TEMPLATE_SERVER/$servername/g" ./$1/*
 sed -i -- "s/TEMPLATE_WORKSPACE/$workspace/g" ./$1/*
}

# Need to reload disk for new job to be visible in the Jenkins.
function reload_disk {
 $JAVA_HOME/bin/java -jar jenkins-cli.jar -s http://testjenkins.com/ reload-configuration --username testuser --password-file myPwd.txt
}

usage(){
 echo "Usage: $0 filename"
 exit 1
}

[[ $# -eq 0 ]] && usage

# Just to check whether the job exists or not.
if [ -d "$1" ]; then
 echo "job $1 already exists"
 exit
fi
create_job $1
modify_job $1
reload_disk

We can store all properties into a file. Below are the example properties stored in the properties file.

test.properties
servername=testserver20
workspace=testworkspace20

Thursday, 24 September 2015

Automation: Silent Installation of Notepad++ in all windows servers.

The goal is to Install Notepad ++ software in all windows servers in a custom location with the help of Jenkins tool.



1) Create a Jenkins job and configure the Jenkins job to connect to all windows boxes with the help of Matrix Project Plugin where you want to install Notepad ++ software.

2) Copy the Notepad ++ software file into a shared path which can be accessed from all windows boxes.

3) Add below batch script to your Jenkins job and Run the Jenkins job.



echo Start DateTime : %date%_%time%

xcopy "\\server1\d$\backup\npp.6.6.8.Installer.exe" "D:\backup" 

cd D:\backup

npp.6.6.8.Installer.exe /S /D=D:\***

del npp.6.6.8.Installer.exe

echo End DateTime : %date%_%time%

Thursday, 27 August 2015

Interview Questions at ORACLE Bangalore

Below are the interview questions asked at Oracle for Build and Release designation with 2 plus years experience.

1. What are your roles and responsibilities?
2. How do you check history in SVN?
3. How to check logs of a particular author in SVN?
4. Describe Hudsons/Jenkins. Which one does your company use?
5. The difference between Hudson and Jenkins?
6. Describe how you deploy your war file and to which server do you deploy?
7. What are the two ways of deploying the war/ear?
8. What is ear?
9. How many environments do you have?
10. What do you provide your customer? Is it EAR/WAR or source code?
11. What Ant installer is used in Jenkins to invoke Ant?
12. Can you write Pre-commit and Post-commit hook script?
13. Did you see your client web app after deployment?

Interview Questions at Speridian Technologies

Below Interview Questions asked at Speridian Technologies for Build and Release profile, for 2 + years experience in Bangalore.

1. What is Version Control System?
2. What is Jenkins?
3. Describe the workflow of your company?
4. what is the process of deploying the patch?
5. If the latest revision of branch contains unstable code/ bugs then from where do we restore our stable  code?
6. What are tags?
7. What is Build Goal? What is POM?
8. What is Build life cycle in Maven?
9. What are the differences between Maven and Ant?
10. How do you deploy your application tool?

Friday, 9 January 2015

How to set permanent environment variables in Ubuntu ?

To set environment variables in Ubuntu:

1) Open /etc/environment file.
   This command helps to edit the file: sudo gedit /etc/environment

2) Add your environment variable in /etc/environment file as shown below.

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/SCM/softwares/gradle-2.2.1/bin:/home//SCM/softwares/apache-ant-1.9.4/bin"


3) Restart your machine.

We can also use export command for setting environment variable. To make it permanent we need to include in ~/.bash_profile or ~/.profile or /etc/profile file.