【问题标题】:Deploy war from Sonatype Nexus using Chef使用 Chef 从 Sonatype Nexus 部署战争
【发布时间】:2014-11-09 19:46:05
【问题描述】:

我正在使用 Chef 来部署我的网络应用程序。目前,我正在使用以下方式部署存储在公司服务器的 sonatype nexus 中的战争。

remote_file "#{base_dir}/webapps/prodservice.war" do
  source "http://company.com:8081/nexus/content/repositories/group/com/company/team/team_product_service/1.0.816/team_product_service-1.0.816.war"
  owner "onamer"
  group "gname"
  notifies :restart, "service[#{service_name}]"
end

有没有办法获得最新的战争而不是硬编码厨师食谱中的版本号?我不想将版本号作为属性也包含在内,因为它需要在每次构建新版本时签入属性文件。我使用下面的 shell 脚本进行战争并将其复制到我的应用程序文件夹,但希望能够与厨师一起完成。

mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get \
        --settings maven-settings.xml \
        -DrepoUrl=http://company.com:8081/nexus/content/repositories/group-snaps \
        -Dartifact=company.team:$project:1.0-SNAPSHOT:war \
        -Ddest=$tmpfile
    cp $tmpfile $tomcat/webapps/$context.war

【问题讨论】:

    标签: java maven chef-infra nexus


    【解决方案1】:

    您想使用 nexus API 构建一个查询,为您提供最新版本的 URL:

    这是一个使用 RGAV 的示例:

    http://company.com:8081/service/local/artifact/maven/redirect?r=REPOg=NAME&a=NAME&v=LATEST
    

    以下是获取最新版本 log4j 的 URL,例如:

    http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=LATEST
    

    然后在你的remote_file 中使用这个 URL:

    remote_file "#{base_dir}/webapps/prodservice.war" do
      source "http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=LATEST"
      owner "onamer"
      group "gname"
      notifies :restart, "service[#{service_name}]"
    end
    

    【讨论】:

      【解决方案2】:

      也许https://github.com/maoo/artifact-deployer 可能有用;这是一本 Chef 食谱(https://github.com/opscode-cookbooks/maven 的包装器),允许您将 Maven GAV 坐标指定为 Chef JSON 属性:

      "artifacts": {
          "alfresco": {
              "enabled": true,
              "groupId": "org.alfresco",
              "artifactId": "alfresco",
              "type": "war",
              "version": "5.0.a",
              "destination": "/var/lib/tomcat7/webapps",
              "owner": "tomcat7"
          }
      }
      

      它还支持其他功能,例如解压缩和属性修补。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多