免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
linux – 如何使用scp將maven3工件部署到遠程服務(wù)器

我想擁有自己創(chuàng)建的工件的maven存儲庫,但我在嘗試將maven 3工件部署到自定義服務(wù)器時遇到問題.為了更好地解釋這一點,我將提供一些信息:

>我正在使用Maven 3
>我正在使用Eclipse Keppler
>我正在使用jenkins
>遠程服務(wù)器正在運行Ubuntu Server 11.04
> Jenkins正在Ubuntu服務(wù)器上運行
>我的本地計算機正在運行Windows XP

我的第一次嘗試是用我的機器.我在Eclipse中運行Maven來進行部署,一切正常.我將以下內(nèi)容添加到我的項目pom中

    <build>           ...        <extensions>            <extension>                <groupId>org.apache.maven.wagon</groupId>                <artifactId>wagon-ssh-external</artifactId>                <version>1.0-beta-6</version>            </extension>        </extensions>          ...      </build>...<distributionManagement>      <repository>          <id>my server id</id>          <name>my repository name</name>          <url>scpexe://my server//path/to/my/repository</url>      </repository>  </distributionManagement>

在我的settings.xml中,我添加了

<servers>        <server>            <id>my server id</id>           <username>server username</username>            <password>server password</password>          <configuration>             <sshExecutable>plink</sshExecutable>             <scpExecutable>pscp</scpExecutable>         </configuration>       </server>   </servers>  

所以在我的本地機器上它可以工作,但我需要使用Jenkins來完成這項工作.我修改了Jenkins settings.xml,因為它在Linux上運行,所以不需要sshExecutable. Jenkins settings.xml看起來像

<servers>        <server>            <id>my server id</id>           <username>server username</username>            <password>server password</password>      </server>   </servers>  

然后我修改了pom.xml來執(zhí)行scp而不是scpexe

<distributionManagement>      <repository>          <id>my server id</id>          <name>my repository name</name>          <url>scp://my server//path/to/my/repository</url>      </repository>  </distributionManagement>

但根據(jù)這個頁面https://cwiki.apache.org/confluence/display/MAVEN/Maven 3.x Compatibility Notes maven 3不支持scp.我以任何方式運行它,我從Jenkins日志中收到以下錯誤消息

mavenExecutionResult exceptions not emptymessage : Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project myproject: Failed to deploy artifacts/metadata: No connector available to access repository my_repository (scp://my server//path/to/my/repository) of type default using the available factories WagonRepositoryConnectorFactorycause : Failed to deploy artifacts/metadata: No connector available to access repository my_repository (scp://my server//path/to/my/repository) of type default using the available factories WagonRepositoryConnectorFactoryStack trace : 

如果我使用scpexe而不是scp,我會收到另一條錯誤消息

mavenExecutionResult exceptions not emptymessage : Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project pruebanueva: Failed to deploy artifacts: Could not transfer artifact {$groupId}:{$artifactId}:{$package}:{$version} from/to my_repository (scpexe://my server//path/to/my/repository): Error executing command for transfercause : Failed to deploy artifacts: Could not transfer artifact {$groupId}:{$artifactId}:{$package}:{$version} from/to my_repository (scpexe://my server//path/to/my/repository): Error executing command for transferStack trace : 

我可以進行部署的唯一方法是分兩步完成

>配置Jenkins以實現(xiàn)安裝目標
>從命令行運行以下命令

mvn deploy:deploy-file -DgroupId=$groupId -DartifactId=$artifactId
-Dversion=$version -Dpackaging=jar -Dfile=path/to/file.jar -Durl=scp://my server//path/to/my/repository -DrepositoryId=my repository id

我嘗試了很多東西,包括將該命令寫入Jenkins目標,但每次我在Jenkins中使用scp命令時,構(gòu)建都會失敗.

任何想法如何解決這個問題將不勝感激.

解決方法:

我有興趣看看是否有任何真正的Maven解決方案.我一直使用Maven Antrun插件修復(fù)此問題,如下所示:

<profile>  <id>deploy</id>  <activation>    <property>      <name>deployment.server</name>    </property>  </activation>  <build>    <plugins>      <plugin>        <groupId>org.apache.maven.plugins</groupId>        <artifactId>maven-antrun-plugin</artifactId>        <version>1.7</version>        <executions>          <execution>            <phase>deploy</phase>            <goals>              <goal>run</goal>            </goals>            <configuration>              <target>                <echo>deploying to server: ${deployment.server}</echo>                <taskdef classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" name="scp" />                <scp file="${project.build.directory}/${project.artifactId}.war" password="${deployment.password}" todir="${deployment.userName}@${deployment.server}:" trust="true" verbose="true" />                <!-- <sshexec command="echo unity | sudo -S cp ${project.build.finalName}.jar $( if [ -e /station ]; then echo /station/lib; else echo /opt/pkg-station*/webapps/station*/WEB-INF/lib; fi )" host="${targetStation}" password="unity" trust="true" username="wps"></sshexec> -->              </target>            </configuration>          </execution>        </executions>        <dependencies>          <dependency>            <groupId>com.jcraft</groupId>            <artifactId>jsch</artifactId>            <version>0.1.25</version>          </dependency>          <dependency>            <groupId>org.apache.ant</groupId>            <artifactId>ant-jsch</artifactId>            <version>1.7.1</version>          </dependency>        </dependencies>      </plugin>      <plugin>        <groupId>org.apache.maven.plugins</groupId>        <artifactId>maven-deploy-plugin</artifactId>        <version>2.7</version>        <configuration>          <skip>true</skip>        </configuration>      </plugin>    </plugins>  </build></profile>

關(guān)于此的一些注意事項:我通過運行到部署階段并提供deployment.server設(shè)置來激活此配置文件.為方便起見,我將相應(yīng)的設(shè)置添加到我的settings.xml中,這樣我就不必每次都在命令行上提供這些設(shè)置:

<profile>    <id>alwaysActiveProfile</id>    <properties>        <deployment.server>10.10.10.10</deployment.server>        <deployment.userName>userName<deployment.userName>        <deployment.password>password</deployment.password>    </properties></profile>

我跳過實際的部署目標,因為它將在我運行到部署階段時執(zhí)行,這是我不想要的.

來源:http://www.icode9.com/content-3-193651.html
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
結(jié)合Maven2進行J2EE項目構(gòu)建
Maven學(xué)習筆記2——向repository上傳artifact
使用maven打包及發(fā)布源碼
使用maven2 進行團隊配置
發(fā)布自己的Android開源庫到JCenter
從零搭建 Spring Cloud 服務(wù)(超級詳細)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服