Search code examples
azuremavenazure-devopsartifactory

Failed to run Maven clean install in azure DevOps


I am trying to do maven clean install in azure DevOps and publish the artifacts into jfrog. However my project is having dependencies. If I run locally by adding jfrog credentials in settings.xml its working, when I try this in azure devops pipeline its failing as it failing to download the dependencies from jfrog.

Here is my YAML Code

trigger:
- master


pool:
 vmImage: ubuntu-latest
steps:
- task: Maven@3
 inputs:
   mavenPomFile: 'pom.xml'
   goals: 'clean deploy'
   publishJUnitResults: true
   testResultsFiles: '**/surefire-reports/TEST-*.xml'
   javaHomeOption: 'JDKVersion'
   mavenVersionOption: 'Default'
   mavenAuthenticateFeed: true
   effectivePomSkip: false



- task: JFrogPublishBuildInfo@1
 inputs:
   artifactoryConnection: 'Token-'
   buildName: '$(Build.DefinitionName)'
   buildNumber: '$(Build.BuildNumber)'

This is my pipeline error enter image description here

what should i do in-order to achieve this. How can I download the dependencies from jfrog artifactory during my build and publish back to jfrog.


Solution

  • Based on your description, you have defined the Jfrog credentials in the settings.xml. And it can work on your local machine.

    In Azure DevOps, you can upload the settings.xml to repo and specify the settings.xml file in the maven task.

    For example: options: '-s settings.xml'

    trigger:
    - master
    
    
    pool:
     vmImage: ubuntu-latest
    steps:
    - task: Maven@3
     inputs:
       mavenPomFile: 'pom.xml'
       goals: 'clean deploy'
       options: '-s filepath/settings.xml'
       publishJUnitResults: true
       testResultsFiles: '**/surefire-reports/TEST-*.xml'
       javaHomeOption: 'JDKVersion'
       mavenVersionOption: 'Default'
       mavenAuthenticateFeed: true
       effectivePomSkip: false
    
    
    - task: JFrogPublishBuildInfo@1
     inputs:
       artifactoryConnection: 'Token-'
       buildName: '$(Build.DefinitionName)'
       buildNumber: '$(Build.BuildNumber)'