如何使用玩自定义模块和持续集成 [英] How to use Play with custom modules and continuous integration

查看:130
本文介绍了如何使用玩自定义模块和持续集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在CI系统中设置Play应用程序和(自定义)Play模块的构建,以便在模块构建良好时,构建会将模块工件安装在本地存储库中和/或将其部署到远程存储库,并且应用程序使用该存储库中的工件?

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 repository and/or deploys them to a remote repository, and the apps use the artifacts in that repository?

该解决方案对于在本地工作的开发人员也应该很好。

The solution should also work well for a developer who's working locally.

我正在使用Jenkins,并以任何方式运行麻烦,我尝试这样做。

I'm using Jenkins, and running in trouble whatever way I try to do this.

在阐述我遇到的所有问题之前,我

Before I elaborate on all the problems I've encountered, I'll wait, because it is laborious, and maybe someone else can offer how they do it.

推荐答案

我有一个安装程序,

首先是自定义模块库的dependencies.yml中的配置

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 -> *

这个开发者和jenkins首先在同一个仓库中搜索是否存在一个模块

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.

要在jenkins中构建我的模块,我使用这样的自定义sh脚本

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

使用这个脚本,你可以将你的模块推送到每个jenkins构建的nexus。这不是我真正的事。我使用jenkins发布模块推它只有当我构建一个版本。对于发布,我有一个特殊的脚本

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"

此脚本在我们的svn存储库中放置一个标签,将模块推送到nexus并更新dependencies.yml文件。

This script put a tag in our svn repository, push the module to nexus and update dependencies.yml file.

使用这个jenkins可以构建一个应用程序,它取决于模块的本地版本,而不是发布,之后,可以通过从nexus存储库下载模块artifcat来构建应用程序。对于开发者来说也是一样的。

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

这篇关于如何使用玩自定义模块和持续集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆