Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
582 views
in Technique[技术] by (71.8m points)

maven - Azure devops not able to connect to jfrog Artifactory

We are using jfrog Artifactory cloud to store maven dependency. we are using these dependencies in pom file. We are able to build from local file as we have added jfrog credentials in .m2/settings.xml file. When we try to run this same thing from azure devops yaml file we are getting authentication error (401 error code)and due to that libraries are not getting download and build is failed. We have added the service connection in azure devops and it is able to connect to jfrog. how to configure build pipeline to access jfrog Artifactory to access libraries?

trigger:
  - main

pool:
  vmImage: "ubuntu-latest"

steps:
  - checkout: self
    lfs: true
  - task: ArtifactoryToolsInstaller@1
    inputs:
      artifactoryService: 'xxxxxxxxxxxxxxxxxxxx'
      cliInstallationRepo: 'jfrog-cli'
      installExtractors: true
      extractorsInstallationRepo: 'jcenter'
  - task: ArtifactoryGenericDownload@3
    inputs:
      specSource: 'taskConfiguration'
      fileSpec: |
        {
          "files": [
            {
              "pattern": "repo/*jar",
              "target": $(System.DefaultWorkingDirectory)/lib
            }
          ]
        }
      failNoOp: true
  - task: Maven@3
    inputs:
      mavenPomFile: "pom.xml"
      mavenOptions: "-Xmx3072m"
      javaHomeOption: "JDKVersion"
      jdkVersionOption: "1.8"
      jdkArchitectureOption: "x64"
      publishJUnitResults: true
      testResultsFiles: "**/surefire-reports/TEST-*.xml"
      goals: "package"
  - publish: $(System.DefaultWorkingDirectory)/target/test.jar
    artifact: artifact
question from:https://stackoverflow.com/questions/65952775/azure-devops-not-able-to-connect-to-jfrog-artifactory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It looks like you're using the Maven task, which is not supported by the Artifactory Azure DevOps extension. This task does not utilize the Artifactory service connection that was configured.

Instead, I'd recommend using the ArtifactoryMaven task. Using this task enforces resolution and deployment to Artifactory and therefore, the settings.xml file is not necessary. This task also publishes to the relevant target deploy repositories.

Basic usage example:

- task: ArtifactoryMaven@1
inputs:
  mavenPomFile: 'pom.xml'
  goals: 'install'
  artifactoryResolverService: 'xxxxxxxxxxxxxxxxxxxx'
  targetResolveReleaseRepo: 'libs-release'
  targetResolveSnapshotRepo: 'libs-snapshot'
  artifactoryDeployService: 'xxxxxxxxxxxxxxxxxxxx'
  targetDeployReleaseRepo: 'libs-release-local'
  targetDeploySnapshotRepo: 'libs-snapshot-local'

You can read more about the Artifactory Maven task here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...