簡體   English   中英

配置jcenter僅用於下載工件,Artifactory用於部署工件

[英]Configure jcenter for only downloading artifacts and Artifactory for deploying artifacts

我們有Artifactory設置,我們使用Maven central repo下載工件,然后自動緩存在Artifactory中。 我們還在Artifactory中上傳/部署我們自己的工件。

我現在想用jcenter 替換 Maven central repo,並希望繼續使用我們的Artifactory來上傳/部署我們自己的工件以及緩存jcenter(以及任何第三方)工件。 我可以要求所有開發人員修改他們的settings.xml文件,因為它將是一次性活動,所以這不是問題。

我在@helmedeiros看到了這個鏈接,它描述了在settings.xml文件的<repositories><pluginRepositories>部分進行更改。 但是,這些是我為Artifactory服務器指定URL的部分。 如果我替換我的Artifactory URL,那么這意味着我將能夠從jcenter獲取和上傳工件,這不是我想要的。

我如何確保所有開發人員只能從jcenter拉取(不部署/上傳)並僅部署/上傳到Artifactory?

以下是我們現在在settings.xml中的內容:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>https://inhouse-artifactory/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>https://inhouse-artifactory/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>https://inhouse-artifactory/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>https://inhouse-artifactory/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

我真的很感謝這方面的任何幫助。

我有完全相同的問題:)

我的解決方案是創建一個Artifactory虛擬存儲庫(forgerock-third-party-virtual)來緩存大多數公共工件。

此虛擬存儲庫包含基於jcenter的遠程存儲庫:

在此輸入圖像描述

在虛擬存儲庫上,沒有默認的部署存儲庫:

在此輸入圖像描述

因此,使用此設置,我希望開發人員無法推入此虛擬存儲庫。

根據JFrog文檔 ,您在此下拉列表中選擇了一個存儲庫,以便能夠進入虛擬存儲庫。

關於部署設置,我們還有一個父pom,我們在<distributionManagement>部分中指定了我們自己的存儲庫。

在我的構建機器上,我添加了這個配置文件(在.m2 / settings.xml中)來緩存工件:

 <profile>
  <id>force-third-party-repo</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <repositories>
    <repository>
      <id>forgerock-third-party</id>
      <name>ForgeRock Third Party Repository</name>
      <url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>
   <pluginRepositories>
    <pluginRepository>
      <id>forgerock-third-party</id>
      <name>ForgeRock Third Party Repository</name>
      <url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>
</profile>

我在此文件中有其他設置來聲明我們自己的Artifactory存儲庫(用於推/拉我們自己的工件)+一些Maven憑據。

我用我們的一個Maven項目做了一些測試,它運行正常。

一旦新的.m2 / settings.xml准備就緒,我將在內部Artifactory存儲庫中推送一個模板,這樣開發人員就可以使用curl命令獲取此模板。

僅供參考,這是暫時的POC。 我們希望在幾天內使用這些設置進行生產。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM