How to use the internet for maven builds instead, if the corporate maven repository is offline or down?

StackOverflow https://stackoverflow.com/questions/23545961

문제

I have a corporate repository defined in my POM:

<distributionManagement>
    <repository>
        <id>central</id>
        <name>libs-release-local</name>
        <url>http://bi-pub.wgresorts.com:8081/artifactory/libs-release-local</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>libs-snapshot-local</name>
        <url>http://bi-pub.wgresorts.com:8081/artifactory/libs-snapshot-local</url>
        <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
</distributionManagement>

But they keep unplugging and moving or rebooting that box, so sometimes it's not available. Is there a way to tell my maven poms "try and use the corporate repository, but if it's down use the internet?" I tried specifying the repository and plugin repository outside of the distribution management section to no avail.

May anyone offer guidance please?

In settings.xml I have a mirror and a local repository defined:

<mirrors>
    <mirror>
        <mirrorOf>*</mirrorOf>
        <name>repo</name>
        <url>http://bi-pub.wgresorts.com:8081/artifactory/repo</url>
        <id>repo</id>
    </mirror>
</mirrors>

<localRepository>C:\apache-maven-3.1.1\.m2\repository</localRepository>

I don't want to have to keep changing the settings.xml depending on the whims of the IT department, can I set it up so it tries the corporate one goes to the internet if it's down?

EDIT

If you used the id central, you'll have to first create a pom with central that points to the real one on the internet before you can fix this. It can also point to your corporate repository but with a different ID. Then it will fall over to the internet if your corporate repository is down.

I think you may also have to delete the mirror section from the settings.xml

도움이 되었습니까?

해결책

For better or worse, binary repository is a critical piece of the production pipeline. You don't ask "what options do I have if my site is down", do you? You just keep your site up. Same story here, your IT department should realize that.

You can run Artifactory in DR mode (active/passive) or even in HA mode (active/active). Your repository has all the means to stay up 24/7, so you really don't need those workarounds.

다른 팁

First of all your settings.xml file is not correct.

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

You have to use the above definition to say maven to search for artifacts as well plugins into the mirror repository (doesn't matter if it's a nexus or artifactory).

As supplemental you have defined uniqueVersion which has no effect starting with Maven 3.

Apart from that the definition in setting.xml is for reading whereas the definition in pom.xml distributionManagement is used for writing which means deploying artifacts or the site.

So in both cases you need the repository up and working as already mentioned by JBaruch. If you IT department is not able to handle such cases (basic IT operations) i would hardly think about that.

Every build in your company depends on the availability of the Repository Manager either for downloading artifacts or for deploying results of the builds and for following steps of the pipeline as well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top