Thursday, November 9, 2023

How to Integrate Artifactory with Azure DevOps | Upload Artifacts from Azure DevOps YAML Pipelines to Artifactory | Artifactory and Azure DevOps Integration | Upload Java WAR file into Artifactory from Azure Pipelines

How to integrate Artifactory with Azure DevOps for uploading build artifacts?



Artifactory is one of the popular binary repository managers. It is Java based open source tool, used for storing build artifacts and docker images.

Some of the key features of Artifactory:
  • Supports 27 different package types including helm charts, docker images regardless of tech stack.
  • A single source of truth for all your binaries
  • Integration with all CICD tools
  • role based authorization with teams to manage artifacts 
  • you can create local, remote and virtual repositories
Pre-requisites:

We will automate building a Java project configured in GitHub and we will use Maven to build, package in Azure YAML pipeline and upload WAR file into Artifactory.

Steps to be followed to create a pipeline:

Create a Pipeline:
Login to your Azure Devops dashboard https://dev.azure.com


Go to Pipelines, Click New
select your SCM, in my case, Java Web App code is in GitHub.



Select the Java Repo, select Maven from the option. This will generate YAML file for us.

Add a task for uploading WAR file.
Click on Show assistant, search for generic and select JFrog Generic Artifacts


Choose Upload as command, choose service connection for Artifactory, enter *.war as pattern, enter repo name where artifact will be uploaded. Click on Add.


Now save the pipeline.. Run the pipeline

Azure DevOps YAML Pipeline Code

using the pipeline code we can automate build using Maven and upload WAR file into Artifactory

# Build your Java project using Maven and Upload WAR file to Artifactory

trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: Maven@3
inputs:
mavenPomFile: 'MyWebApp/pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
- task: JFrogGenericArtifacts@1
inputs:
command: 'Upload'
connection: 'Artifactory_svc_conn'
specSource: 'taskConfiguration'
fileSpec: |
{
"files": [
{
"pattern": "*.war",
"target": "libs-snapshot-local"
}
]
}
failNoOp: true

Now login to Artifactory..Click on Artifactory --> Artifacts. We can see the WAR file being uploaded.


This is how we can easily integrate Artifactory with Azure DevOps for uploading build artifacts.

Watch Steps in YouTube channel:

No comments:

Post a Comment

How to Configure GitHub Advanced Security for Azure DevOps | How to Perform Security scan for Azure Repos using GitHub Advanced Security

GitHub Advanced Security for Azure DevOps brings the  secret scanning, dependency scanning  and  CodeQL code scanning  solutions already ava...