8

मैं सीआई सिस्टम में प्ले ऐप्स और (कस्टम) प्ले मॉड्यूल कैसे बना सकता हूं ताकि जब मॉड्यूल का निर्माण अच्छा हो, तो बिल्ड स्थानीय मॉड्यूल में मॉड्यूल कलाकृतियों को स्थापित करता है भंडार और/या उन्हें एक दूरस्थ भंडार में तैनात करता है, और ऐप्स उस भंडार में कलाकृतियों का उपयोग करते हैं?कस्टम मॉड्यूल और निरंतर एकीकरण के साथ Play का उपयोग कैसे करें

समाधान को डेवलपर के लिए भी अच्छी तरह से काम करना चाहिए जो स्थानीय रूप से काम कर रहा है।

मैं जेनकींस का उपयोग कर रहा हूं, और जिस तरह से मैं इसे करने की कोशिश करता हूं, परेशानी में चल रहा हूं।

इससे पहले कि मैंने सामना की सभी समस्याओं पर विस्तार से पहले, मैं इंतजार करूंगा, क्योंकि यह श्रमिक है, और शायद कोई और यह पेशकश कर सकता है कि वे इसे कैसे करते हैं।

उत्तर

6

मेरे पास जेनकींस में एक सेटअप है जो देव से उत्पादन के लिए अच्छी तरह से काम करता है।

यहां पहली कस्टम मॉड्यूल भंडार के लिए dependencies.yml में विन्यास

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 -> * 
इस डेवलपर्स के साथ

और जेनकींस एक ही भंडार में सबसे पहले खोज करते हैं एक मॉड्यूल मौजूद है और यदि नहीं देख रहा है, मिल गया आर्टिफैक्ट डाउनलोड करने के लिए नेक्सस भंडार।

जेनकींस में मेरी मॉड्यूल का निर्माण करने के मैं इस

#!/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 "[email protected]/$APPLICATION-$VERSION.zip" --verbose 
इस स्क्रिप्ट आप गठजोड़ करने के लिए अपने मॉड्यूल पुश करने के लिए पर एक जेनकींस निर्माण में सक्षम हैं के साथ

की तरह एक कस्टम श स्क्रिप्ट का उपयोग। यह वास्तव में मैं नहीं करता हूं। मैं जेनकिंस रिलीज मॉड्यूल का उपयोग केवल तभी दबाता हूं जब मैं रिलीज करता हूं। एक रिलीज के लिए मैं एक विशेष स्क्रिप्ट

#!/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 "[email protected]/$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 भंडार में एक टैग डाल दिया है, मॉड्यूल नेक्सस और dependencies.yml फ़ाइल अद्यतन करने के लिए धक्का।

इस जेनकींस एक ऐप बना सकते हैं जो मॉड्यूल के स्थानीय संस्करण पर रिलीज़ होने पर निर्भर करता है और उसके बाद नेक्सस रिपोजिटरी से मॉड्यूल आर्टिफैट डाउनलोड करके ऐप बना सकता है। डेवलपर्स

+1

मुझे लगता है कि इस तकनीक को अपना सेटअप में एक फर्क करने जा रहा है; मेरे पास अभी तक कोशिश करने का समय नहीं है, इसलिए मैंने इसे अभी तक स्वीकार नहीं किया है। फॉलो-अप प्रश्न: आपके स्थानीय मॉड्यूल रेपो कॉन्फ़िगरेशन ऐसा नहीं लगता है कि यह एक सामान्य जेनकींस सेटअप से मेल खाता है, जहां बिल्ड वर्कस्पेस आसन्न निर्देशिका में नहीं हैं। मैं थोड़ा उलझन में हूं जहां से आपकी जेनकींस देव के लिए निर्भरताएं पुनर्प्राप्त करती हैं (रिलीज के विपरीत) संस्करण। – Ladlestein

+1

जेनकींस में मेरे पास केवल एक कार्यक्षेत्र है और मेरी सभी मॉड्यूल निर्देशिकाएं देव के रूप में आसन्न हैं। यदि नहीं, तो आपको हर बार एक मॉड्यूल बनाने के दौरान अपने आर्टेफैक्ट को नेक्सस में प्रकाशित करना होगा, किसी प्रकार का स्नैपशॉट वर्जनिंग जो सेटअप और उपयोग के लिए अधिक कठिन होगा –

2

के लिए यह वही बात है मैंने इस छोटे से प्ले को लिखा था! आदेश है कि मूल रूप से यह वही काम करता है, लेकिन Play में अच्छी तरह से एकीकृत करता है!

http://www.playframework.org/community/snippets/25

from play.utils import * 
from poster.encode import multipart_encode 
from poster.streaminghttp import register_openers 
import urllib 
import urllib2 
import yaml 

COMMANDS = ['nexus-commit',] 

HELP = { 
    'nexus-commit': 'push built module to nexus' 
} 

def execute(**kargs): 
    app = kargs.get("app") 
    args = kargs.get("args") 
    play_env = kargs.get("env") 

    print '~ ' 
    print '~ Commiting to nexus server' 
    print '~ ' 

    app.check() 
    nexus = app.readConf('nexus.server.url') 
    user = app.readConf('nexus.server.user') 
    password = app.readConf('nexus.server.password') 

    if nexus: 
     print '~ Found nexus repository : %s' % nexus 
    else: 
     print '~ No nexus server configured' 
     print '~ Set up the following on your application.conf:' 
     print '~ nexus.server.url' 
     print '~ nexus.server.user' 
     print '~ nexus.server.password' 
     sys.exit(0) 

    #Getting module version from dependencies file 
    deps_file = os.path.join(app.path, 'conf', 'dependencies.yml') 
    if os.path.exists(deps_file): 
     f = open(deps_file) 
     deps = yaml.load(f.read()) 
     #Is this a Play~ module? 
     if "self" in deps: 
      d = deps["self"].split(" ") 
      module_version = d.pop() 
      app_name = d.pop() 
     else: 
      app_name = app.name() 
      print '~ This is not a Play module' 
      module_version = app.readConf('application.version') 
      if not module_version: 
       print '~ ' 
       print '~ No application.version found in application.conf file' 
       print '~ ' 
       module_version = raw_input('~ Provide version number to be pushed to Nexus:') 
     f.close 

    if module_version: 
     print '~ Module version : %s' % module_version 
     print '~ ' 
    else: 
     print '~ No module version configured.' 
     print '~ Configure your dependencies file properly' 
     sys.exit(0) 

    dist_dir = os.path.join(app.path, 'dist') 

    #Only interested on .zip files 
    for root, dirs, files in os.walk(dist_dir): 
     files = [ fi for fi in files if fi.endswith(".zip") ] 

    #Loop over all found files 
    if len(files) >0: 
     for file in files: 
      if "-a" in args: 
       #We won't ask the user if he wants to commit 
       resp = "Y" 
      else: 
       resp = raw_input('~ Do you want to post %s to nexus? (Y/N) ' % file) 
      if resp == 'Y': 
       url = '%s/%s/%s-SNAPSHOT/%s-%s-SNAPSHOT.zip' % (nexus, app_name, module_version, app_name, module_version) 
       print '~ ' 
       print '~ Sending %s to %s' % (file, url) 

       try: 
        data = open(os.path.join(dist_dir, file), 'rb') 
       except: 
        print '~ Error: could not open file %s for reading' % file 
        continue 

       openers = register_openers() 
       #post data to Nexus using configured credentials 
       passman = urllib2.HTTPPasswordMgrWithDefaultRealm() 
       passman.add_password(None, url, user, password) 
       authhandler = urllib2.HTTPBasicAuthHandler(passman) 
       openers.add_handler(authhandler) 
       openers.add_handler(urllib2.HTTPHandler(debuglevel=1)) 
       datagen, headers = multipart_encode({"file": data}) 
       request = urllib2.Request(url, datagen, headers) 

       try: 
        print urllib2.urlopen(request).read() 
        print '~ File correctly sent' 
       except urllib2.HTTPError, err: 
        print '~ Error: Nexus replied with -- %s' % err 

      else: 
       print '~ ' 
       print '~ Skiping %s' % file 
    else: 
     print '~ ' 
     print '~ No module build found.' 
     print '~ Try "play build-module" command first' 
     print '~ ' 
संबंधित मुद्दे