How to should I setup my CI (jenkins) for deb packages?

Skarab picture Skarab · Sep 7, 2012 · Viewed 8.7k times · Source

I have a CI setup with Jenkins and Artifactory for Java. I would like also to build and deploy deb packages. For building deb packages, I might use a Maven plugin (called from Gradle), e.g., http://mojo.codehaus.org/deb-maven-plugin/.

I am now investigating Debian repository implementations. I would like to deploy a private Debian repository to host my packages (http://wiki.debian.org/HowToSetupADebianRepository).

Are there any plugin in Jenkins that would make it easier to deploy deb packages? Which debian repository implementation should I use?

Answer

stuart-warren picture stuart-warren · Dec 10, 2013

Just adding my 2 cents to this post.

Internally we use Freight (https://github.com/rcrowley/freight#readme) as our Debian/Ubuntu repository.

A lot of us tend to use fpm (https://github.com/jordansissel/fpm#readme) by Jordan Sissel for creating debs for internal use. This can be easily scripted inside your source repository like I do here: https://github.com/stuart-warren/logit/blob/master/make-deb

#!/bin/bash

# SET SOME VARS
installdir='/usr/lib/logit'
NAME='logit-java'
VERSION='0.5.8'
ITERATION='1'
WEBSITE='https://github.com/stuart-warren/logit'
REPO='http://nexus.stuartwarren.com/nexus'

# REMOVE PREVIOUS BUILD IF PRESENT
echo "Delete ${installdir}"
rm -rf .${installdir}

# CREATE FOLDER STRUCTURE
echo "create base dir ${installdir}"
mkdir -p .${installdir}

# PUT FILES IN THE CORRECT LOCATIONS
wget ${REPO}/content/repositories/releases/com/stuartwarren/logit/${VERSION}/logit-${VERSION}-tomcatvalve.jar -O .${installdir}/logit-${VERSION}-tomcatvalve.jar
wget ${REPO}/content/repositories/releases/com/stuartwarren/logit/${VERSION}/logit-${VERSION}-jar-with-dependencies.jar -O .${installdir}/logit-${VERSION}-jar-with-dependencies.jar
wget https://raw.github.com/stuart-warren/logit/master/LICENSE -O .${installdir}/LICENCE
wget https://raw.github.com/stuart-warren/logit/master/README.md -O .${installdir}/README.md
pushd .${installdir}
ln -sf logit-${VERSION}-tomcatvalve.jar logit-tomcatvalve.jar
ln -sf logit-${VERSION}-jar-with-dependencies.jar logit-jar-with-dependencies.jar
popd

# REMOVE OLD PACKAGES
echo "Delete old packages"
rm ${NAME}_*_all.deb

# CREATE THE DEB
echo "Build new package"
fpm \
        -n $NAME \
        -v $VERSION \
        --iteration ${ITERATION} \
        -a all \
        -m "Stuart Warren <[email protected]>" \
        --description "Library to extend Log4J 1.2 (plus now Logback 1.0, 
Java.util.logging and Tomcat AccessLog Valve) by providing 
json layouts (for logstash/greylog) and a zeromq appender" \
        --url $WEBSITE \
        --license 'Apache License, Version 2.0' \
        --vendor 'stuartwarren.com' \
        -t deb \
        -s dir \
        ${installdir:1}

echo "Delete ${installdir}"
rm -rf .${installdir}
echo "Done!"

Obviously you could just copy in any compiled files directly rather than downloading from a server, maven repo in my case. Then you can SCP the deb upto some 'incoming' directory on your repository server.