azure - 通过 Azure Pipeline 将 Maven 构建部署到 Azure Artifacts 时如何修复 401?

标签 azure maven azure-pipelines artifacts

我在 Azure Artifacts (azure-maven) 中创建了 feed,添加了 MavenAuthenticate 任务来构建管道(使用 artifactsFeeds: azure-mave),将 mavenAuthenticateFeed: true 添加到 Maven 任务,将存储库添加到 pom.xml 中。 xml 具有相同的 ID,但部署 Maven 任务时失败并显示 401(未经授权)。

我是否遗漏了某个步骤?

(如果我没有的话,我不想使用 PAT,这不是使用 MavenAuthenticate 任务的原因吗?)

干杯, 史蒂夫

最佳答案

嗯,看起来问题实际上是将 mavenAuthenticateFeed 设置为 true,这对我来说没有意义:(

这是工作 yml:

trigger:
- main

variables:
  - name: MAVEN_CACHE_FOLDER
    value: $(Pipeline.Workspace)/.m2/repository
  - name: MAVEN_OPTS
    value: -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: MavenAuthenticate@0
  inputs:
    artifactsFeeds: 'azure-maven'

- task: Cache@2
  inputs:
    key: 'maven | "$(Agent.OS)" | pom.xml'
    path: '$(MAVEN_CACHE_FOLDER)'
    cacheHitVar: 'CacheRestored'
    restoreKeys: |
      maven | "$(Agent.OS)"
      maven
  displayName: Cache Maven local repo

- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'package deploy'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    mavenVersionOption: 'Default'
    mavenOptions: '-Xmx3072m $(MAVEN_OPTS)'
    mavenAuthenticateFeed: false
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    effectivePomSkip: false
    sonarQubeRunAnalysis: false

- task: CopyFiles@2
  inputs:
    Contents: '**/target/*.jar'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
    CleanTargetFolder: true
    flattenFolders: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'Test'
    publishLocation: 'Container'

关于azure - 通过 Azure Pipeline 将 Maven 构建部署到 Azure Artifacts 时如何修复 401?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65841795/

相关文章:

azure-devops - Azure Release Pipelines - 是否可以在另一个阶段完成之前阻止手动触发阶段

azure - Azure Pipelines 中失败任务的自定义错误消息

Azure PHP Web 应用广告集成 请求中指定的回复 URL 不匹配

Maven 存储库

performance - Windows Azure 中的自定义性能计数器

java - Maven - 如何安装/部署带时间戳的快照

java - 在 Sonar 中排除生成的代码

azure - 如何排除不在包含范围内的所有内容 - Azure DevOps YAML Pipeline

本地开发时未创建 Azure Functions 表绑定(bind)

Azure Functions 和 Azure 应用程序网关或 API 管理