How can I set up builds of Play apps and (custom) Play modules in a CI system so that when a module\'s build is good, the build installs the module artifacts in a local reposito
I have a setup in jenkins that works well from dev to production.
First here is the configuration in the dependencies.yml for the custom module repository
repositories:
- modules:
type: chain
using:
- localModules:
type: local
descriptor: "${application.path}/../[module]/conf/dependencies.yml"
artifact: "${application.path}/../[module]"
- repoModules:
type: http
artifact: "http://mynexus/nexus/content/repositories/releases/com/myorg/[module]/[revision]/[module]-[revision].zip"
contains:
- com.myorg -> *
With this developers and jenkins search firstly in the same repository to see if a module is present and if not, got to the nexus repository to download the artifact.
To build my module in jenkins I use a custom sh script like this
#!/bin/bash
APPLICATION="myModule"
PLAY_PATH="/usr/local/play"
set –xe
$PLAY_PATH/play deps --sync
$PLAY_PATH/play build-module --require 1.2.3
VERSION=`grep self conf/dependencies.yml | sed "s/.*$APPLICATION //"`
echo "Sending $APPLICATION-$VERSION.zip to nexus repository"
curl --request POST --user user:passwd http://mynexus/nexus/content/repositories/releases/com/myorg/$APPLICATION/$VERSION/$APPLICATION-$VERSION.zip -F "file=@dist/$APPLICATION-$VERSION.zip" --verbose
With this script you are able to push your module to nexus on each jenkins build. This is not really what I do. I use jenkins release module to push it only when I build a release. For a release I have a special script
#!/bin/bash
APPLICATION="myModule"
PLAY_PATH="/usr/local/play"
set –xe
if [ -z "$RELEASE_VERSION" ]
then
echo "Parameter RELEASE_VERSION is mandatory"
exit 1
fi
if [ -z "$DEVELOPMENT_VERSION" ]
then
echo "Parameter DEVELOPMENT_VERSION is mandatory"
exit 1
fi
echo "Release version : $RELEASE_VERSION"
echo "Development version : $DEVELOPMENT_VERSION"
VERSION=`grep self conf/dependencies.yml | sed "s/.*$APPLICATION //"`
if [ "$RELEASE_VERSION" != "$VERSION" ]
then
echo "Release version $RELEASE_VERSION and play version $VERSION in dependencies.yml does not match : release failed"
exit 1
fi
REVISION=`svnversion .`
echo "Tag svn repository in revision $REVISION with version $VERSION"
svn copy -m "Version $VERSION" -r $REVISION http://mysvn/myRepo/$APPLICATION/trunk/ http://mysvn/myRepo/$APPLICATION/tags/$VERSION
echo "svn tag applied"
echo "Sending $APPLICATION-$VERSION.zip to nexus repository"
curl --request POST --user user:passwd http://mynexus/nexus/content/repositories/releases/com/myorg/$APPLICATION/$VERSION/$APPLICATION-$VERSION.zip -F "file=@dist/$APPLICATION-$VERSION.zip" --verbose
echo "$APPLICATION-$VERSION.zip sent to nexus repository"
echo "Update module to version $DEVELOPMENT_VERSION"
sed -i "s/self\(.*\)$VERSION/self\1$DEVELOPMENT_VERSION/g" conf/dependencies.yml
svn commit -m "Version $DEVELOPMENT_VERSION" conf/dependencies.yml
svn update
echo "Version $DEVELOPMENT_VERSION créée"
This script put a tag in our svn repository, push the module to nexus and update dependencies.yml file.
With this jenkins can build an app which depends on a local version of the module while it is not released and after that can build the app by downloading the module artifcat from the nexus repository. It is the same thing for developers