资讯专栏INFORMATION COLUMN

如何使用wagon插件来解放你的双手

Object / 2140人阅读

摘要:问题有什么用怎么用有什么优势是插件中的一种,其作用是去除我们部署时繁复的步骤,不用再手动上传包或者包到指定服务器路径下面。

问题

有什么用?

怎么用?

有什么优势?


wagon是maven插件中的一种,其作用是去除我们部署时繁复的步骤,不用再手动上传jar包或者war包到指定服务器路径下面。

使用

pom.xml

    
        
            
                org.codehaus.mojo
                wagon-maven-plugin
                1.0
                
                  
                    demo-test
                  
                    target/
                  
                    ${project.artifactId}.jar
                  
                    scp://172.168.1.11:22/opt/micservice
                  
                    apps/${project.artifactId}
                  
                    
                        cd /opt/micservice/ ; ./dev restart ${project.artifactId} test
                    
                  
                    true
                
            
        
        
            
                org.apache.maven.wagon
                wagon-ssh
                2.8
            
        
    

setting.xml


    
        与上面的serverId一致
        demo-test
        username
        password
    

配置完成后,运行命令:

mvn clean package wagon:upload wagon:sshexec

wagon:upload-single是上传jar或者war包

wagon:sshexec是执行配置中的shell命令

如果不想执行上面的这么长串命令,也可以使用execution


    
        
            org.apache.maven.wagon
            wagon-ssh
            2.8
        
    
    
        
            org.codehaus.mojo
            wagon-maven-plugin
            1.0
            
                
                    upload-deploy
                    
                    package
                    
                        upload-single
                        sshexec
                    
                    
                        mylinuxserver
                        target/javawebdeploy.war
                        scp://192.168.20.128/coder/tomcat/apache-tomcat-7.0.55/webapps
                        
                            sh /coder/tomcat/apache-tomcat-7.0.55/bin/shutdown.sh
                            rm -rf /coder/tomcat/apache-tomcat-7.0.55/webapps/javawebdeploy
                            sh /coder/tomcat/apache-tomcat-7.0.55/bin/startup.sh
                        
                        true
                    
                
            
        
    

以上mvn clean package 来代替 mvn clean package wagon:upload-single wagon:sshexec,但个人觉得不是特别适合开发时期,我觉得还是使用命令的方式执行,或者通过自己写一个shell文件,需要的时候执行一下即可。

Tips

关于一些goals

wagon:upload-single uploads the specified file to a remote location.

wagon:upload uploads the specified set of files to a remote location.

wagon:download-single downloads the specified file from a remote location.

wagon:download downloads the specified set of files from a remote location.

wagon:list lists the content of a specified location in a remote repository.

wagon:copy copies a set of files under a Wagon repository to another.

wagon:merge-maven-repos merges , including metadata, a Maven repository to another.

wagon:sshexec Executes a set of commands at remote SSH host.

其他的标签

skip属性,boolean类型,默认是true,作用是忽略execution

优势

去除了发布的重复动作,直接一个命令就可以完成

将人为的错误降低了,工作更加高效

链接

官方文档

更多内容可以关注微信公众号,或者访问AppZone网站

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/35844.html

相关文章

  • 如何使用wagon插件解放你的双手

    摘要:问题有什么用怎么用有什么优势是插件中的一种,其作用是去除我们部署时繁复的步骤,不用再手动上传包或者包到指定服务器路径下面。 问题 有什么用? 怎么用? 有什么优势? wagon是maven插件中的一种,其作用是去除我们部署时繁复的步骤,不用再手动上传jar包或者war包到指定服务器路径下面。 使用 pom.xml ...

    fyber 评论0 收藏0
  • 神器!解放你的双手——UI设计稿全自动切图和标注的一些工具推荐

    摘要:蓝湖通过帮助设计师更好地向团队展示设计图描述页面之间的跳转关系。如果设计图出现改动和更新,蓝湖也能自动添加新版本。蓝湖基于这些反馈快速迭代,而自动标注功能就是其中一项。 原文收录在我的 GitHub博客 (https://github.com/jawil/blog) ,喜欢的可以关注最新动态,大家一起多交流学习,共同进步,以学习者的身份写博客,记录点滴。 工欲善其事,必先利其器。我只是...

    lylwyy2016 评论0 收藏0
  • 神器!解放你的双手——UI设计稿全自动切图和标注的一些工具推荐

    摘要:蓝湖通过帮助设计师更好地向团队展示设计图描述页面之间的跳转关系。如果设计图出现改动和更新,蓝湖也能自动添加新版本。蓝湖基于这些反馈快速迭代,而自动标注功能就是其中一项。 原文收录在我的 GitHub博客 (https://github.com/jawil/blog) ,喜欢的可以关注最新动态,大家一起多交流学习,共同进步,以学习者的身份写博客,记录点滴。 工欲善其事,必先利其器。我只是...

    tianren124 评论0 收藏0

发表评论

0条评论

Object

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<