簡體   English   中英

Maven 發布:在 azure 管道上執行失敗,因為它無法讀取 repo 的密碼

[英]Maven release:perform on azure pipeline fails as it can't read password for the repo

我有一個使用 maven-release-plugin 的父 pom,其中需要將工件推送到 Azure 工件。 我能夠讓它在我的本地工作,現在正在嘗試使用 azure 管道自動化它,但我得到了mvn release:perform的以下錯誤。

錯誤:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:perform (default-cli) on project my-parent-repo: Unable to checkout from SCM
[ERROR] Provider message:
[ERROR] The git-clone command failed.
[ERROR] Command output:
[ERROR] Cloning into 'checkout'...
[ERROR] fatal: could not read Password for 'https:********@dev.azure.com': terminal prompts disabled
[ERROR] -> [Help 1]

我的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<scm>
    <developerConnection>scm:git:https://$(PAT)@dev.azure.com/my-org/my-prjt/_git/my-parent-repo/</developerConnection>
  <tag>HEAD</tag>
</scm>
<groupId>dispute</groupId>
<artifactId>my-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Microservice DI parent</name>
<description>DI microservice parent </description>
<distributionManagement>  
  <!-- Publish the versioned releases here -->  
  <repository>  
    <id>repo</id>  
    <name>Artifact repo</name>  
    <url>https://xxx.pkgs.visualstudio.com/2abc/_packaging/my-maven-artifacts/maven/v1</url>  
  </repository>  
</distributionManagement>  

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>3.0.0-M1</version>
  </plugin>
</plugins>
</build>

<repositories>
    <repository>
        <id>my-maven-artifacts</id>
        <url>
            https://xxx.pkgs.visualstudio.com/2abc/_packaging/my-maven-artifacts/maven/v1
        </url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>Pod4-artifacts</id>
        <url>
            https://xxx.pkgs.visualstudio.com/2abc/_packaging/my-maven-artifacts/maven/v1
        </url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

<properties>
    <!-- Build properties -->
    <maven.version>3.3.9</maven.version>
    <java.version>11</java.version>
</properties>
</project>

已嘗試修復:我已啟用Allow scripts to access the OAuth token 我還為 Project Collection Service Accounts 和 Project Collection Build Service 提供了在 Repositories 下創建標簽、分支和貢獻的權限。 Also, have a ci-settings.xml with the username and password for the repo id, which am providing as arguments in the Maven task in the Azure pipeline. -e -B -s $(System.DefaultWorkingDirectory)/ci-settings.xml

如果有什么遺漏,請告訴我。 請注意,它在我當地運行良好。

由於您使用的是 PAT 令牌而不是 OAuth 令牌,因此我們不需要啟用選項Allow scripts to access the OAuth token 如果你想使用這個,你可以使用這個 URL

https://$env:SYSTEM_ACCESSTOKEN@dev.azure.com/my-org/my-prjt/_git/my-parent-repo

我們應該在 select repo 權限下為賬戶Project Collection Build Service(Org name)提供創建標簽、分支、貢獻的權限,而不是在All Repositories權限頁面下配置權限。

我們也可以嘗試在 pom 文件中設置PAT token而不是變量。

暫無
暫無

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

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