How do I configure my CI (jenkins) for deb packages?

I have a CI setup with Jenkins and Artifactory for Java. I would also like to create and deploy deb packages. To create deb packages, I could use the Maven plugin (called Gradle), for example http://mojo.codehaus.org/deb-maven-plugin/ .

Now I will explore the implementations of the Debian repository. I would like to deploy a private Debian repository to host my packages ( http://wiki.debian.org/HowToSetupADebianRepository ).

Is there a plugin in Jenkins that will make it easier to deploy deb packages? Which debian repository implementation should I use?

+4
source share
4 answers

I am not aware of the Debian plug-in for Jenkins, and I have not found the maven-deb-plugin suitable for my needs (see "What Doesn't Work" on the page you linked to). When I have work on creating maven in Jenkins, I add a post step shell script that increments the version in debian / changelog and runs dpkg-buildpackage -b -nc.

-nc suppresses the clean before build, which is necessary because my debian / rules file would otherwise try to run maven targets to build the jars that Jenkins had already made. Snippet from my debian / rules:

pre-built-stamp mvn package touch pre-built-stamp override_dh_auto_build: pre-built-stamp 

So, after maven steps in Jenkins, the following is done

 touch pre-built-stamp dpkg-buildpackage -b -nc 

This part is a personal preference, but I don't have Jenkins that pops the built-in debate directly into my repository. Instead, it saves the .deb and .changes files as build artifacts, so I can use the Promoted Builds plugin to sign the .changes file and copy it to the repository (rsync). This allows my developers to download and test deb before claiming it will be ported to our staging repository. Then the second promotion can be used to transfer the package to a live repository.

I chose reprepro as our repository manager. One of its main drawbacks is that it cannot handle more than one version of a package in a distribution, which makes rollback more painful. In addition, he found it reliable and usable, and now uses it to completely mirror the main Debian repositories, as well as use it to host my private repositories.

Reprepro uses inoticoming to identify new incoming packages and verify the signature in the change file, ensuring that only Jenkins can add new packages.

I found that some of the documentation in the reprefs is missing, but I recommend installing it and reading the reprepro and inoticoming man pages.

+3
source

Debian Package Developers Plugin for Jenkins

+3
source

Just add my 2 cents to this post.

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

Many of us tend to use fpm ( https://github.com/jordansissel/fpm#readme ) from Jordan Sissel to create deb for internal use. This can be easily created in your source repository, as I am 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 < stuart@stuartwarren.com >" \ --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 directly to any compiled files, and not download maven repo from my server in my case. You can then execute SCP deb to some "inbound" directory on the repository server.

+2
source

Yes, there is a plugin that helps with the deployment of Debian packages in the package repository. The Debian package developers plugin has two functions: a build step (which you don't need) and a post-build publish step . Target repositories are configured in the system configuration. Just select one of them in the job setup. The plugin uses dupload (1) "under the hood".

As the repository manager for Debian packages, I recommend Aptly . It is powerful, easy to use, well-documented and actively developing.

0
source

Source: https://habr.com/ru/post/1433038/


All Articles