nexus/maven 部署到 Nexus 服务器的旧 IP

nexus/maven deploy to old IP of nexus server

我为 jenkins master 使用 RHEL7 的 AWS EC2 实例,并在上面安装了 sonarqube、nexus、maven..。安装和配置后,我 运行 在 jenkins 上做了一些工作,一切似乎都很好,后来我的服务器似乎挂了,所以我不得不停止并启动它。这使得RHEL服务器的IP改变了。

现在,当我尝试 运行 一项执行 maven 部署的工作时...sonarqube 试图访问旧服务器 IP,我在 jenkins> 全局配置中进行了更改。所以 sonarqube 现在工作正常。但在那之后,maven 试图访问我的旧服务器 IP 和 nexus 端口。我不知道在哪里可以修改。

Ps:我 运行 的工作来自不属于我的 git 存储库,我没有克隆它,所以让我们考虑没有访问权限到该项目的 pom.xml 文件。

我按照这个安装了 nexus [1] https://devopscube.com/how-to-install-latest-sonatype-nexus-3-on-linux/
Git 项目 URL: https://github.com/vemular1/dev-maxo-demo/

我在部署时遇到的错误,maven 部署 repo 是针对旧 IP。

 --- maven-install-plugin:2.4:install (default-install) @ maxotech ---
[INFO] Installing /var/lib/jenkins/workspace/deploy/target/maxotech-1.4.jar to /var/lib/jenkins/.m2/repository/com/maxo/maxotech/1.4/maxotech-1.4.jar
[INFO] Installing /var/lib/jenkins/workspace/deploy/pom.xml to /var/lib/jenkins/.m2/repository/com/maxo/maxotech/1.4/maxotech-1.4.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ maxotech ---
Uploading to deploymentRepo: http://35.193.152.132:8081/repository/maven-releases/com/maxo/maxotech/1.4/maxotech-1.4.jar
Uploading to deploymentRepo: http://35.193.152.132:8081/repository/maven-releases/com/maxo/maxotech/1.4/maxotech-1.4.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:20 min
[INFO] Finished at: 2018-06-20T13:47:39Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project maxotech: Failed to deploy artifacts: Could not transfer artifact com.maxo:maxotech:jar:1.4 from/to deploymentRepo (http://35.193.152.132:8081/repository/maven-releases/): Connect to 35.193.152.132:8081 [/35.193.152.132] failed: Connection timed out (Connection timed out) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

我是 Whosebug 的新手,如果我没有按照格式post请告诉我。

在重启后使用您的 EC2 实例新分配的 IP 更新您的 pom.xml 并刷新您的 Maven 项目。

mvn clean install -U

此外,正如您正确提到的重启后 IP 更改,您可能需要为您的实例设置一个弹性 IP,这样您就不必每次都执行此更改。

<distributionManagement>
    <repository>
        <id>deploymentRepo</id>
        <name>Internal Releases</name>
        <url>http://35.193.152.132:8081/repository/maven-releases/</url>
    </repository>

    <snapshotRepository>
        <id>deploymentRepo</id>
        <name>Internal Releases</name>
        <url>http://35.193.152.132:8081/repository/maven-snapshots/</url>
    </snapshotRepository>

</distributionManagement>