Suresh Payankannur

Tuesday, August 18, 2015

Ubuntu + Jenkins + Gradle + Embedded Tomcat + Port 80

Port 80 is a privileged port and normal users cannot listen on this port. I had a recent requirement to run some test cases on an embedded tomcat running on Port 80 during Jenkins build. Here is the steps worked for me to achieve this.

Gradle File

apply plugin: 'java'
apply plugin: 'war'

buildscript {
  repositories {
  dependencies {
    classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'

apply plugin: 'com.bmuschko.tomcat'

tomcat {
  httpPort = 80
  contextPath = "/"

Setup authbind

authbind will allow non-root user to listen on privileged ports.
sudo apt-get install authbind
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80 
sudo chown jenkins /etc/authbind/byport/80

Configure Jenkins

Modify the Jenkins run command (last line in do_start routine)to the following
$SU -l $JENKINS_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- authbind --deep $JAVA $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS" || return 2


Post a Comment

Blog Archive

Scroll To Top