Home > Software engineering >  Publish custom maven artifact/package (*.jar) to Azure artifact using azure DevOps pipeline
Publish custom maven artifact/package (*.jar) to Azure artifact using azure DevOps pipeline

Time:09-24

I want to push my custom artifact/package (*.jar) to the Azure artifact using maven with the help of Azure DevOps pipeline. I am using java & building the package using maven.

I can do it by the below script/command in the Azure pipeline.

 mvn deploy:deploy-file -DgroupId="com.mypkg" `
-DartifactId="my.artifact" `
-Dversion="1.0.0-SNAPSHOT" `
-Dpackaging=jar `
-Dfile="my.artifact-1.0.0-SNAPSHOT.jar" `
-DgeneratePom="true" `
-DrepositoryId="$AZURE_FEED_ID" `
-Durl="$AZURE_FEED_URL";

I want to know if this can be done by any Azure pipeline task like "- task: Maven@3" Because Azure DevOps provides the publish tasks for npm, Gradel, Python etc but not for maven.

CodePudding user response:

I want to know if this can be done by any Azure pipeline task like "- task: Maven@3"

Yes, the maven deploy step can be done via Maven task.

Here is an example:

- task: Maven@3
  displayName: 'Maven pom.xml'
  inputs:
    mavenPomFile: pom.xml
    goals: 'deploy:deploy-file'
    options: '-DgroupId="com.mypkg"  -DartifactId="my.artifact" -Dversion="1.0.0-SNAPSHOT"  -Dpackaging=jar -Dfile="my.artifact-1.0.0-SNAPSHOT.jar" -DgeneratePom="true" -DrepositoryId="$AZURE_FEED_ID" -Durl="$AZURE_FEED_URL"'

The deploy command can be defined at goals field and the arguments can be defined at options field.

For more info, you can refer to the doc about Maven task.

  • Related