【问题标题】:Maven release:perform on azure pipeline fails as it can't read password for the repoMaven 发布:在 azure 管道上执行失败,因为它无法读取 repo 的密码
【发布时间】:2021-01-05 14:25:36
【问题描述】:

我有一个使用 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 下创建标签、分支和贡献的权限。 此外,还有一个 ci-settings.xml,其中包含 repo id 的用户名和密码,它们在 Azure 管道中的 Maven 任务中作为参数提供。 -e -B -s $(System.DefaultWorkingDirectory)/ci-settings.xml

如果有什么遗漏,请告诉我。请注意,它在我的本地运行良好。

【问题讨论】:

    标签: azure-devops azure-pipelines maven-release-plugin


    【解决方案1】:

    由于您使用的是 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
    

    我们应该提供Project Collection Build Service(Org name)账户在select repo权限下创建标签、分支、贡献的权限,而不是在All Repositories权限页面下配置权限。

    我们也可以尝试在 pom 文件中设置 PAT token 而不是变量。

    【讨论】:

      猜你喜欢
      • 2022-11-28
      • 2013-03-11
      • 2011-01-20
      • 1970-01-01
      • 2020-09-01
      • 1970-01-01
      • 2020-01-30
      • 2020-04-02
      • 1970-01-01
      相关资源
      最近更新 更多