How to Setup Configure Hudson Master Slave? – Complete Guide

hudson-master-slave-setup
The tasks can be scheduled to run on the same machine (Master), or on a different machine (Slave). A master is a installation of Hudson, that can manage one or more slaves. The role of master remains same in Master slave setup. It serves HTTP requests, and it can still build projects on it’s own.
Slaves are computers that are setup to build projects triggered from the master. A separate program called slave agent runs on slave computer. In this article we’ll discuss about how to setup Hudson to executed distributed builds using Master slave. One computer can be configured to execute multiple slave agents.

How it works

When the slaves are registered to a master, the master starts distributing loads to slaves. The delegation depends on the specific job. The job can be configured to either execute on the master, or it can be tied to a specific slave. On the other hand, the jobs can be configured to freely roam between slaves, wherein the job is executed using the free slave. As per the user is concerned, the setup is transparent. The results for all jobs are viewable using the Master, irrespective of the Slave that executed the job.
The slave may be built using any Operating system. The Master slave setup is highly helpful while the user has to execute the job on different Operating system. Consider this use case: The application is expected to run on different operating system, Linux, Solaris and Windows system. To address this need, the user can install Hudson on any machine, say Linux, and add 2 slaves: Solaris and Windows. The user can add 3 different jobs, one running on Master itself and others running on slave machines.

Methods to set up Slave agents

The slave can be launched from Master using any of below methods:
  1. Launch Slave agents on Unix machines via SSH.
  2. Launch Slave agents via JNLP.
  3. Launch Slave agents via execution of command on the master.
  4. Let Hudson control windows slave as a windows service.

The following screenshot illustrates the list of modes under which the Hudson slave can be launched.

Set up Slave agents on Unix machines via SSH

Hudson has a built-in SSH client implementation that it can use to talk to remote sshd and start a slave agent. This is the most convenient and preferred method for Unix slaves, which normally has sshd out-of-the-box. Click Manage Hudson, then Manage Nodes, then click New Node. In this set up, the connection information is supplied, including SSH host name, user name and authentication credentials. The authentication is performed using password or ssh keys. If it is configured to use ssh keys, the SSH public key should be copied to ~/.ssh/authorized_keys file. Hudson will do the rest of the work by itself, including copying the binary needed for a slave agent, and starting/stopping slaves.

 

Depending on the project and hardware resource availability, the user Desktop can be used as one of Slave, without affecting his day-to-day activities, thus avoiding the need for dedicated Slaves.

Establish slave agent via Java Web Start

Another way of launching slave is to start a slave agent through Java Web Start (JNLP). In this approach, the user will login to the slave node, open a browser and open the slave page using the URL pointed to the Master. It may look like the following URL:
http://masterserver:port/hudson/jnlpJars/slave.jar
The user is presented with the JNLP launch icon. If user click the icon, the Java Web Start kicks in and it launches a slave agent on this computer.
This mode is convenient when the master cannot initiate a connection to slaves, such as when it runs outside a firewall while the rest of the slaves are in the firewall. The disadvantage is, if the machine with a slave agent goes down, the master has no way of re-launching it on its own.

Set up slave agent headlessly

This launch mode uses a mechanism very similar to Java Web Start, except that it runs without using GUI, making it convenient for an execution as a daemon on Unix. To do this, the user should configure this slave to be a JNLP slave by downloading slave.jar, and then from the slave, run a command like this:
 
java -jar slave.jar -jnlpUrl http://yourserver:port/computer/slave-name/slave-agent.jnlp

The slave.jar file is downloaded from the above mentioned URL. Make sure to replace slave-name with the name of the slave setup in Master.

By default, Hudson runs on port 8080. It can be installed and managed without the need for super user privilege. The super user privilege is not required to manage both Master and Slave.

The below diagram illustrates the list of configuration parameters specific to a slave.

 

set up Slave Agent using own scripts

If the above modes is not flexible, the user can write his own script to launch the Slave agent. The script is placed in the Master computer and Hudson runs this script whenever it should connect to the slave. The script may use the remote login program like SSH, RSH to establish connection between Master and slave.
The script would execute the slave agent program like java -jar slave.jar. The stdin and stdout for the script should be connected to the master. For example, the script that does ssh myslave java -jar ~/bin/slave.jar would satisfy this need, when it is executed from the Master web interface. For this reason, running this script manually from the command line does no good.
The copy of slave.jar can be downloaded from the above mentioned URL. Launching the slave agent using this mode requires additional setup in the Slave. The benefit is that when the connection goes bad, the user can use Hudson web interface to re-establish the connection.
Tagged : / / / / / / / / / / / / / / / /

How to put comment in Ant | Comments in Apache Ant

comments-in-apache-ant

How to put comment in Ant | Comments in Apache Ant

Method 1:

<!– Comments are just as important in buildfiles, do not –>
<!– avoid writing them! –>
<!– Example build file for “Ant: The Definitive Guide” –>
<!– and its sample project: irssibot –>

Method 2: Echo
Description
Writes a message to the Ant logging facilities. A message may be supplied
as nested text to this task.
Echoes a message to the current loggers and listeners which means System.out unless overridden. A level can be specified, which controls at what logging level the message is filtered at.
The task can also echo to a file, in which case the option to append rather than overwrite the file is available, and the level option is ignored

Parameters

Attribute Description

Required

message the message to echo.

No. Text may also be included in a character section within this element. If neither is included a blank line will be emitted in the output.

file the file to write the message to.

No

append Append to an existing file (or open a new file / overwrite an existing file)?

No – default is false.

level Control the level at which this message is reported. One of “error”, “warning”, “info”, “verbose”, “debug” (decreasing order)

No – default is “warning”.

encoding encoding to use, default is “”; the local system encoding. since Ant 1.7

No

Examples
Style 1:
<echo message=”Hello, world”/>

Style 2:
<echo message=”Embed a line break:${line.separator}”/>

Style 3:
<echo>Embed another:${line.separator}</echo>

Style 4:
<echo>This is a longer message stretching over
two lines.
</echo>

Style 5:
<echo>
This is a longer message stretching over
three lines; the first line is a blank
</echo>

Style 5:
<echo message=”Deleting drive C:” level=”debug”/>
A message which only appears in -debug mode.

Style 6:
<echo level=”error”>
Imminent failure in the antimatter containment facility.
Please withdraw to safe location at least 50km away.
</echo>
A message which appears even in -quiet mode.

Style 7:
<echo file=”runner.csh” append=”false”>#\!/bin/tcsh
java-1.3.1 -mx1024m ${project.entrypoint} $$*
</echo>
Generate a shell script by echoing to a file. Note the use of a double $ symbol to stop Ant filtering out the single $ during variable expansion
Depending on the loglevel Ant runs, messages are print out or silently ignored:

Ant-Statement

-quiet, -q

no statement

-verbose, -v

-debug, -d

<echo message=”This is error message.” level=”error” />

ok

ok

ok

ok

<echo message=”This is warning message.” />

ok

ok

ok

ok

<echo message=”This is warning message.” level=”warning” />

ok

ok

ok

ok

<echo message=”This is info message.” level=”info” />

not logged

ok

ok

ok

<echo message=”This is verbose message.” level=”verbose” />

not logged

not logged

ok

ok

<echo message=”This is debug message.” level=”debug” />

not logged

not logged

not logged

ok

Method 3:
Description

Tagged : / / / / / / / / / / / / /

How to run ant build in intellij? – IntelliJ/Ant integration Guide

intellij-ant-integration

IntelliJ/Ant integration
By Alvin J. Alexander, devdaily.com
The fact that IntelliJ is off-the-shelf ready to work with Ant is a great, great feature. It’s also simple to configure and use.
Assuming that you already know how to use Ant, and you have a build.xml file ready to go, just follow these steps to (a) configure your build script to run from within IntelliJ, and (b) run Ant:

  • Assuming you’re in an IntelliJ project, select 6: Ant Build from the slide-in menu bar (“Tool Window Bar”) on the right side of your screen.
  • Click the large plus sign icon to add your build.xml file to IntelliJ’s list of known build scripts for this project.
  • Navigate the filesystem until you find your build script (i.e., your build.xml file for this project). Select that file.
  • To run a desired Ant task, double-click the task name that you want to run. My main task is usually named deploy, so I double-click that.
  • Ant should run properly for you, and deploy your application.

It’s really that simple.
The worst problem I’ve run into so far is that when I work on projects on multiple computer systems, my build scripts rely on an environment parameter named ANT_HOST_NAME existing. So, when my build script failed the first time, I said “Oh, dummy Al, you need to set your ANT_HOST_NAME environment parameter. Once I did this and restarted IntelliJ, the Ant build process worked like a champ.
Kudos, dear IntelliJ developers. Great product feature!

Best Example of <Copy>
Type 1:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts” includes=”BuildSh,Compsh,vsamc,buildc.sh,script,compl2,main.sh,makefile,makepl1,script” />
</copy>

Type 2:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts” includes=”BuildSh,Compsh,vsamc,buildc.sh,script,compl2,main.sh,makefile,makepl1,script” />
</copy>

Type 3:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts”>
<include name=”BuildSh”/>
<include name=”Compsh”/>
<include name=”vsamc”/>
</fileset>

</copy>

Type4:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts”>
<includesfile name=”${List}/Uaw_compilescripts_list.txt”/>
</fileset>
</copy>

 

Tagged : / / / / / / / / / /

A sample Ant build script that builds a WAR file – Guide

ant-build-script-war-file

A sample Ant build script that builds a WAR file

<project name=”MyWebApplication” basedir=”..” default=”install”>

<!– project-specific variables –>
<property name=”jsp.dir.name” value=”myapp” />
<property name=”package.name” value=”${jsp.dir.name}.war” />
<property name=”webapp.dir” value=”/Users/al/tomcat-6.0.16/webapps” />

<property environment=”env” />
<property name=”build.dir” value=”build” />
<property file=”${build.dir}/build.${env.HOSTNAME}” />

<property name=”lib.dir” value=”lib” />
<property name=”pages.dir” value=”pages” />
<property name=”src.dir” value=”src” />
<property name=”src.tests.dir” value=”src-tests” />
<property name=”resources.dir” value=”resources” />
<property name=”dest.dir” value=”target” />

<!– put everything in a temp folder with the right structure during the build –>
<property name=”temp.dir” value=”temp” />
<property name=”temp.dir.web-inf” value=”${temp.dir}/WEB-INF” />
<property name=”temp.dir.lib” value=”${temp.dir.web-inf}/lib” />
<property name=”temp.dir.classes” value=”${temp.dir.web-inf}/classes” />
<property name=”temp.dir.meta-inf” value=”${temp.dir}/META-INF” />

<property name=”package.file” value=”${dest.dir}/${package.name}” />

<path id=”build.class.path”>
<fileset dir=”lib”>
<include name=”**/*.jar” />
</fileset>
</path>

<target name=”clean”>
<delete>
<fileset dir=”${dest.dir}” includes=”**/*”/>
</delete>
<delete dir=”${temp.dir}” />
<delete dir=”${temp.dir.classes}” />
<delete dir=”${temp.dir.meta-inf}” />
<delete dir=”${temp.dir.web-inf}” />
</target>

<target name=”prepare” depends=”clean”>
<mkdir dir=”${dest.dir}” />
<mkdir dir=”${temp.dir}” />
<mkdir dir=”${temp.dir.lib}” />
<mkdir dir=”${temp.dir.meta-inf}” />
<mkdir dir=”${temp.dir.web-inf}” />
<mkdir dir=”${temp.dir.classes}” />
</target>

<!– COMPILE –>
<target name=”compile” depends=”prepare”>
<echo>=== COMPILE ===</echo>
<echo>Compiling ${src.dir} files …</echo>
<javac debug=”on” srcdir=”${src.dir}” destdir=”${temp.dir.classes}” includes=”**/*”>
<classpath refid=”build.class.path” />
</javac>

<!– compile files on the src-tests path –>
<echo>Compiling ${src.tests.dir} files …</echo>
<javac debug=”on” srcdir=”${src.tests.dir}” destdir=”${temp.dir.classes}” includes=”com/**”>
<classpath refid=”build.class.path” />
</javac>
</target>

<!– PACKAGE –>
<target name=”package” depends=”compile”>
<echo>=== PACKAGE ===</echo>

<!– copy the config files –>
<copy file=”${resources.dir}/MANIFEST.MF” tofile=”${temp.dir.meta-inf}/MANIFEST.MF” overwrite=”true” />
<copy file=”${resources.dir}/web.xml” tofile=”${temp.dir.web-inf}/web.xml” overwrite=”true” />
<copy file=”${resources.dir}/managed-beans.xml” tofile=”${temp.dir.web-inf}/managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/navigation-rules.xml” tofile=”${temp.dir.web-inf}/navigation-rules.xml” overwrite=”true” />

<copy todir=”${temp.dir.classes}”>
<fileset dir=”${src.dir}”>
<include name=”**/*.xml”/>
<include name=”**/*.xsl”/>
</fileset>
</copy>

<!– with all resources in place, create the war file –>
<war destfile=”${package.file}” webxml=”${temp.dir.web-inf}/web.xml” basedir=”${temp.dir}”>
<fileset dir=”${pages.dir}”/>
<lib dir=”${lib.dir}” />
<classes dir=”${temp.dir.classes}” />
</war>
</target>

<!– JUST DEPLOY JSP’s –>
<target name=”jsps”>
<echo>=== DEPLOY JSP’S ===</echo>
<!– i’m trying to be explicit about what i put out there –>
<copy todir=”${webapp.dir}/${jsp.dir.name}”>
<fileset dir=”${pages.dir}”>
<include name=”**/*.jsp”/>
<include name=”**/*.html”/>
<include name=”**/*.css”/>
<include name=”**/*.gif”/>
<include name=”**/*.jpg”/>
<include name=”**/*.png”/>
<include name=”**/*.js”/>
</fileset>
</copy>
</target>

<!– INSTALL –>
<target name=”install” depends=”package”>
<echo>=== INSTALL ===</echo>
<copy file=”${package.file}” tofile=”${webapp.dir}/${package.name}” overwrite=”true” />
</target>

</project>

Tagged : / / / / / / / / / / / / / / / / /

Simple Ant Example – clean, prepare, and compile tasks

ant-clean-prepare-and-compile-tasks

Sample Ant clean, prepare, and compile tasks

<target name=”clean”>
<echo>=== CLEAN ===</echo>
<delete failonerror=”false”>
<fileset dir=”${dest.dir}” includes=”**/*”/>
</delete>
<delete dir=”${temp.dir}” />
</target>

<target name=”prepare” depends=”clean”>
<echo>=== PREPARE ===</echo>
<mkdir dir=”${dest.dir}” />
<mkdir dir=”${temp.dir}” />
<mkdir dir=”${temp.dir.lib}” />
<mkdir dir=”${temp.dir.meta-inf}” />
<mkdir dir=”${temp.dir.web-inf}” />
<mkdir dir=”${temp.dir.classes}” />
</target>

<target name=”compile” depends=”prepare”>
<echo>=== COMPILE ===</echo>
<echo>Compiling ${src.dir} files …</echo>
<javac debug=”on” srcdir=”${src.dir}” destdir=”${temp.dir.classes}” includes=”**/*”>
<classpath refid=”build.class.path” />
</javac>

<!– compile files on the src-tests path –>
<echo>Compiling ${src.tests.dir} files …</echo>
<javac debug=”on” srcdir=”${src.tests.dir}” destdir=”${temp.dir.classes}” includes=”com/**”>
<classpath refid=”build.class.path” />
</javac>
</target>

Tagged : / / / / / / / / / / / / / / / /

Samples/Examples of the Ant copy task – Guide

ant-copy-task

Samples of the Ant copy task

<copy file=”${resources.dir}/MANIFEST.MF” tofile=”${temp.dir.meta-inf}/MANIFEST.MF” overwrite=”true” />
<copy file=”${resources.dir}/managed-beans.xml” tofile=”${temp.dir.web-inf}/managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/navigation-rules.xml” tofile=”${temp.dir.web-inf}/navigation-rules.xml” overwrite=”true” />
<copy file=”${resources.dir}/monitoring-managed-beans.xml” tofile=”${temp.dir.web-inf}/monitoring-managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/monitoring-navigation-rules.xml” tofile=”${temp.dir.web-inf}/monitoring-navigation-rules.xml” overwrite=”true” />
<copy file=”${resources.dir}/faces-config.xml” tofile=”${temp.dir.web-inf}/faces-config.xml” overwrite=”true” />
<copy file=”${resources.dir}/log4j.properties” tofile=”${temp.dir.classes}/log4j.properties” overwrite=”true” />
<copy file=”${resources.dir}/commons-logging.properties” tofile=”${temp.dir.classes}/commons-logging.properties” overwrite=”true” />

<copy todir=”${temp.dir.classes}”>
<fileset dir=”${src.dir}”>
<include name=”**/*.xml”/>
<include name=”**/*.xsl”/>
<include name=”**/*.properties”/>
</fileset>
</copy>

<copy todir=”${dist}”>
<fileset dir=”${src}”
includes=”**/images/*”
excludes=”**/*.gif”
/>
</copy>

This copies all files in directories called images that are located in the directory tree defined by ${src} to the destination directory defined by ${dist}, but excludes all *.gif files from the copy.

<copy todir=”${dist}”>
<fileset dir=”${src}”>
<include name=”**/images/*”/>
<exclude name=”**/*.gif”/>
</fileset>
</copy>

The same as the example above, but expressed using nested elements.

<delete dir=”${dist}”>
<include name=”**/images/*”/>
<exclude name=”**/*.gif”/>
</delete>

Deleting the original set of files, the delete task can act as an implicit fileset.

Flatten directories when performing an Ant copy
Here’s a code snippet from an Ant build script where I begin with a hierarchical structure of jar files in my development environment, then flatten out all my lib subdirectories into one directory in my production environment when I copy all the jar files to my production library directory:

<!– build a temporary lib dir, and flatten out the jars into one folder –>

<copy todir=”${temp.dir.lib}” flatten=”true”>
<fileset dir=”${lib.dir}”>
<exclude name=”${cob.lib.dir}” />
<exclude name=”junit*” />
<include name=”**/*.jar”/>
<include name=”**/*.zip”/>
</fileset>
</copy>

 

Tagged : / / / / / / / / /

| SVN | Subversion | SVN pros and Cons| SVN Repository Planning | SVN Repository layout

svn-pros-and-cons

| SVN | Subversion | SVN pros and Cons| SVN Repository Planning | SVN Repository layout |

Subversion (SVN) Repository Layout

Single Project – One project per repository location

Pros

· Isolated revision numbers

· Isolated codebase

· Isolated security model

Cons

· Isolated codebase

· Multiple Urls to remember

· Multiple locations to maintain

Multi-Project Layout – Several projects in one repository

Pros

· Easy to merge code between projects

· Single url for all projects

· One repository to maintain

Cons

· Revision numbers span across all projects

· Harder to isolate users to appropriate repositories

Tagged : / / / / / / / / /

Sonar PDF Report Plugin 2.1 – What is new in Sonar PDF Report Plugin 2.1?

sonar-pdf-report-plugin

Hi all,

I’m proud to announce the availability of a new release of Sonar
PDF Report Plugin (Commercial edition):
http://blog.klicap.es/products/sonarpdfreportplugin

Key features of this new release:

* Include information provided by other installed plugins
* Possibility of use SVG images in front page and header

Actually Sonar PDF Report Plugin 2.1 supports integration with:
* Technical Debt Plugin
* SIGMM Plugin
* Total Quality PLugin
* Quality Index Plugin
* Taglist Plugin

Regards,
Antonio.

Tagged : / / / / / / / / / / / / / / / / /

Sonar 2.2 Released – Know what’s new in Sonar 2.2 ?

sonar-2.2

Sonar 2.2 Released – Know what’s new in Sonar 2.2 ?

The Sonar Team is pleased to announce the release of Sonar 2.2. There are two key features in this new version :

 

1. Filters

Users can define filters that allow to add new tabs on the homepage like :

  • all projects
  • projects analyzed during last 3 days
  • unit tests with longest execution time
  • classes of a given project with coverage < 50% and complexity>10
  • treemap of projects with a given maven groupId
  • my favourites (each resource : project, package, file, … can be flagged as favourite)

 

 

Administrators can customize the default filters displayed in the homepage and users can define their own filters.
Some screenshots :

 

 
2. Plugin classloaders
Plugins are now executed in independent classloaders. The main advantage is that plugins can declare their own dependencies instead of being limited to Sonar libraries. That’s a major improvement for developing plugins.

More details in the section “How to use external dependencies?”

of the documentation. You can read also this page

to know how to upgrade existing plugins.

 
 

On top of those 2 features, this release contains more than 60 improvements and bug-fixes (see the release notes

), including Checkstyle/PMD upgrades and support of Clover 3. To enjoy the new version, you can download it straight away

.

 

Special thanks to all the contributors who provided patches, gave their feedback or helped us improving Sonar.

– The Sonar team

Tagged : / / / / / / / / / / /

Website Typography

website-typography

Below is a list with arrows. To use this style create a list in the following format:

    • ….
    • ….

  • Quisque ultrices etiam, class nec velit vestibulum sit congue pulvinar, mattis penatibus proin odio placerat ante.

To use this style create a list in the following format:

    • ….
    • ….

  • Quisque ultrices etiam, class nec velit vestibulum sit congue pulvinar, mattis penatibus proin odio placerat ante.

Below is a list with circle. To use this style create a list in the following format:

    • ….
    • ….

  • Quisque ultrices etiam, class nec velit vestibulum sit congue pulvinar, mattis penatibus proin odio placerat ante.

 

Alert box

This is a sample pin note. Use Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer urna. Aenean tristique. Fusce a neque. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Info box

This is a sample pin note. Use Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer urna. Aenean tristique. Fusce a neque. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Download box

This is a sample pin note. Use Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer urna. Aenean tristique. Fusce a neque. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Code
#subheader h1 {
float: left;
margin-top: 28px;
background: url(../images/logo.gif) no-repeat;
width: 335px;
height: 58px;
text-indent: -9999px;
}

 

Tagged : / / / / / / / / / / / / /