DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • How to LINQ Between Java and SQL With JPAStreamer
  • 13 Impressive Ways To Improve the Developer’s Experience by Using AI
  • Tactics and Strategies on Software Development: How To Reach Successful Software [Video]
  • Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs

Trending

  • How to LINQ Between Java and SQL With JPAStreamer
  • 13 Impressive Ways To Improve the Developer’s Experience by Using AI
  • Tactics and Strategies on Software Development: How To Reach Successful Software [Video]
  • Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Starting a Hudson Slave on a Unix Machine Without SSH

Starting a Hudson Slave on a Unix Machine Without SSH

John Ferguson Smart user avatar by
John Ferguson Smart
·
Jun. 03, 10 · Interview
Like (0)
Save
Tweet
Share
5.41K Views

Join the DZone community and get the full member experience.

Join For Free

One great feature about Hudson is the support for distributed builds. Distributed builds can be used to absorb load or for specialized build jobs such as system or functional testing or automated deployments. In this article, we look at a special case - what happens when you need to start a Unix Hudson slave from the slave machine itself.

The best way to start a Hudson slave on a Unix build box is to use SSH. This is very convenient (all you need is a valid SSH account on the slave machine), and can be initiated automatically as required from the Hudson master. However, in some organizations, SSH is not installed on the machines, which makes this approach impossible.

If you can't use SSH, you can still start the slave by running a command on the command line. Hudson provides a special JAR file, called slave.jar, for this purpose. You can get this file from your Hudson server using a URL like http://buildserver.myorg.com/hudson/jnlpJars/slave.jar (where "http://buildserver.myorg.com/hudson" is the URL you are running Hudson on).

To start the slave agent, you invoke the slave.jar file as shown here:

java -jar slave.jar -jnlpUrl http://build.myorg.com/hudson/computer/test-slave/slave-agent.jnlp

Of course, you will also want to stop the slave agent. A more complete script, that lets you both start and stop the slave agent, is shown here:

#/bin/sh
HUDSON_MASTER=http://build.myorg.com/hudson

start(){
 wget $HUDSON_MASTER/jnlpJars/slave.jar
 START = java -jar slave.jar -jnlpUrl $HUDSON_MASTER/computer/test-slave/slave-agent.jnlp 
 nohup $START > hudson.log 2>&1 &
 echo "Hudson slave started"
}

stop(){
 kill `ps -ef | grep hudson | grep slave | grep -v grep | awk '{ print $2 }'`
 echo "Hudson slave stopped"
}

status(){
 numproc=`ps -ef | grep hudson | grep slave | grep -v grep | awk  | wc -l`
 if [ $numproc -gt 0 ]; then
  echo "Hudson slave is running..."
  else
  echo "Hudson slave is stopped..."
 fi
}

restart(){
  stop
  start
}

# See how we were called.
case "$1" in
start)
 start
 ;;
stop)
 stop
 ;;
status)
 status
 ;; 
restart)
 restart
 ;;
*)
 echo $"Usage: $0 {start|stop|status|restart}"
 exit 1
esac

exit 0
This script will work will under most Linux distros. Some Unix variants, such as HP, don't have wget installed by default, so you will need to either find an equivalent or (a work-around that I've been known to use) store the slave.jar file under version control and check it out. In this case, it is important to keep the JAR file stored in Subverion in sync with the version of Hudson you are running. For example, an HP-friendly variant of this script using Subversion might look like this:
start(){
 svn up
 START = java -jar slave.jar -jnlpUrl $HUDSON_MASTER/computer/test-slave/slave-agent.jnlp 
 nohup $START > hudson.log 2>&1 &
 echo "Hudson slave started"mr_}

This script is now ready to be installed as a service on your Unix slave machine.

From http://weblogs.java.net/blog/johnsmart/archive/2010/06/02/starting-hudson-slave-unix-machine-without-ssh

Hudson (software) Machine

Opinions expressed by DZone contributors are their own.

Trending

  • How to LINQ Between Java and SQL With JPAStreamer
  • 13 Impressive Ways To Improve the Developer’s Experience by Using AI
  • Tactics and Strategies on Software Development: How To Reach Successful Software [Video]
  • Microservices Decoded: Unraveling the Benefits, Challenges, and Best Practices for APIs

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: