首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jenkins + maven货运+2只猫

Jenkins + maven货运+2只猫
EN

Stack Overflow用户
提问于 2014-07-26 18:11:44
回答 1查看 997关注 0票数 1

我正在用maven构建由Jenkins编写的war文件,我需要同时将它部署到两个正在运行的tomcats中。我在pom.xml中编写了两个配置文件(每个tomcat),但是当我运行时

代码语言:javascript
复制
cargo:deploy -Pprofile1,profile2

它只部署到profile2。所以我需要运行命令2次:

代码语言:javascript
复制
cargo:deploy -Pprofile1 
cargo:deploy -Pprofile2

这就是我的pom.xml的样子:

代码语言:javascript
复制
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.8</version>
            <configuration>
                <container>
                    <containerId>tomcat7x</containerId>
                    <type>remote</type>
                </container>
                <configuration>
                    <type>runtime</type>
                    <properties>
                        <cargo.remote.uri>${cargo.manager.url}</cargo.remote.uri> 
                        <cargo.remote.username>${cargo.username}</cargo.remote.username>
                        <cargo.remote.password>${cargo.password}</cargo.remote.password>
                    </properties> 
                </configuration>
                <deployables>
                    <deployable>
                        <groupId>com.softserveinc</groupId>
                        <artifactId>oms</artifactId>
                        <!-- <version>1.0.0-BUILD-SNAPSHOT</version> -->
                        <type>war</type>
                    </deployable>
                </deployables>
            </configuration>
        </plugin>       
    </plugins>
</build>
<profiles>
    <profile>
        <id>profile1</id>
            <properties>
            <cargo.manager.url>http://<here shuold be ip addres>/manager/text</cargo.manager.url>
            <cargo.username>admin</cargo.username>
            <cargo.password>admin</cargo.password>
       </properties>
    </profile>
    <profile>
        <id>profile2</id>
        <properties>
            <cargo.manager.url>http://<here shuold be ip addres>/manager/text</cargo.manager.url>
            <cargo.username>admin</cargo.username>
            <cargo.password>admin</cargo.password>
        </properties>
    </profile>
</profiles>

但我需要用一个命令来对付两只猫?有人知道怎么做吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-24 13:40:47

编写调用货运部署命令的脚本。

下面是Jinja模板,它从ansible库存文件中动态创建:

代码语言:javascript
复制
#!/bin/sh
function deploy
{
echo "Changing working directory to om"
cd /home/install/some

{% for host in groups['app'] %}
echo "Deploying application to {{host}} server"
{{installation_folder}}/maven/bin/mvn cargo:redeploy -P{{host}}
{% endfor %}
}

echo "Downloading the latest version of oms.war"
wget "http://{{groups['CS'][0]}}:8081/nexus/service/local/artifact/maven/redirect?r=snapshots&g=com.softserveinc&a=oms&v=1.0.0-BUILD-SNAPSHOT&p=war" -O /tmp/some.war

deploy

echo "Removing some.war"
rm -rf /tmp/oms.war
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24974049

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档