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
- Artifactory is installed, up and running
- Install only JFrog Extension by using Azure Devops Market place. do NOT install JFrog Artifactory extn.
- Service connection is created in Azure Devops for connecting to Artifactory
- Service connection for connecting to GitHub from Azure Devops using Personal Access Token
- Java based webapp is configured in GitHub
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
select your SCM, in my case, Java Web App code is in GitHub.
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