Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当通过Azure管道将Maven build部署到Azure工件时,如何修复401?_Azure_Maven_Azure Pipelines_Artifacts - Fatal编程技术网

当通过Azure管道将Maven build部署到Azure工件时,如何修复401?

当通过Azure管道将Maven build部署到Azure工件时,如何修复401?,azure,maven,azure-pipelines,artifacts,Azure,Maven,Azure Pipelines,Artifacts,我已经在Azure工件(Azure maven)中创建了feed,将MavenAuthenticate任务添加到构建管道中(带有工件feed:Azure mave),将mavenAuthenticateFeed:true添加到maven任务中,将存储库添加到具有相同ID的pom.xml中,但是部署maven任务时失败,401(未经授权) 有没有我错过的一步 (如果没有,我不想使用PAT,这不是使用MavenAuthenticate任务的原因吗?) 干杯, Steve嗯,看起来问题实际上是将mav

我已经在Azure工件(Azure maven)中创建了feed,将MavenAuthenticate任务添加到构建管道中(带有工件feed:Azure mave),将mavenAuthenticateFeed:true添加到maven任务中,将存储库添加到具有相同ID的pom.xml中,但是部署maven任务时失败,401(未经授权)

有没有我错过的一步

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

干杯,
Steve

嗯,看起来问题实际上是将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'

如果提供您自己的settings.xml:

  <servers>
    <server>
      <id>azure-maven</id>
      <username>AzureDevOps</username>
      <password>${env.SYSTEM_ACCESSTOKEN}</password>
    </server>
  </servers>

如果提供您自己的settings.xml:
- task: DownloadSecureFile@1
  name: mvnSettings
  inputs:
    secureFile: 'settings.xml'
- task: Maven@3
  env:
    SYSTEM_ACCESSTOKEN: $(System.AccessToken)
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'clean deploy'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    mavenVersionOption: 'Default'
    options: '-s $(mvnSettings.secureFilePath)'
    mavenOptions: '-Xmx3072m $(MAVEN_OPTS)'
    mavenAuthenticateFeed: false
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    effectivePomSkip: false
    sonarQubeRunAnalysis: false