Tuesday, 18 February 2014

Running Jenkins on Tomcat with SSL


1) Download java rpm using wget. ( Download java using wget )
2) Login root using su root. Then install it using rpm -ivh rpmname.rpm
3) Be sure that you can access java, javac, keytool commands.
4) Download tomcat and jenkins
5) Move jenkins var to tomcat webapps dir using mv jenkins.war ${TOMCAT_DIR}/webapps
6) Create self signed certificate using keytool -genkey -alias tomcat -keyalg RSA -keystore ${KEYSTORE_FILE_PATH} -validity 365
7) It is going to ask questions about your organisation and such. Please answer them. Pick your password as well
8) In ${TOMCAT_DIR}/conf/server.xml find the line starting with <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"... Uncomment it and add the following attribute values keystoreFile="${KEYSTORE_FILE_PATH}" keystorePass="password"
9) Start tomcat using ${TOMCAT_DIR}/bin/startup.sh. Check both http://localhost:8080/jenkins and http://localhost:8443/jenkins if everything is ok.

Prevent SSH root login

For preventing the root login from ssh, please open the ssh config file using the following command.


vi /etc/ssh/sshd_config

Find the line starting PermitRootLogin. Uncomment it (remove # character) and change value to following

PermitRootLogin no 

Hope it helps

Maven - add existing jars to local repository

In order to add existing jars into the local maven repository, please use the command below.

mvn install:install-file -Dfile=${JAR_FULL_PATH} -DgroupId=${UNIQUE_GID}  -DartifactId=${UNIQUE_ARTIFACTID} -Dversion=${VERSION} -Dpackaging=jar 

And add the dependency in pom.xml as follows.

<dependency>
   <groupId>${UNIQUE_GID}</groupId>
   <artifactId>${UNIQUE_ARTIFACTID}</artifactId>
   <version>${VERSION}</version>
</dependency>

The second way to achieve this is to add system scoped dependency with the system path. 

<dependency>
   <groupId>${UNIQUE_GID}</groupId>
   <artifactId>${UNIQUE_ARTIFACTID}</artifactId>
   <version>${VERSION}</version>
   <scope>system</scope>
   <systemPath>${basedir}/${JAR_RELATIVE_PATH}</systemPath>
</dependency> 

Please be cautious about this, since it breaks maven's dependency system. Most probably, you will see a warning in the maven build output as follows.

Some problems were encountered while building the effective model for X
[WARNING] 'dependencies.dependency.systemPath' for X should not point at files within the project directory, ${basedir}/Y will be unresolvable by dependent projects  


Hope it helps.