π» Windows Environment: All commands optimized for Windows PowerShell.
β οΈ Prerequisites Check:
- Days 12-13 complete (tests and coverage working)
- Maven and .NET projects from previous days
- Azure Pipeline configured and running
- Tests passing with good coverage
Lab 1: Publish Maven JAR Artifacts π¨
Objective: Build and publish Java JAR file as artifact
Time: 30 minutes
Exercise 1.1: Update Maven Pipeline
1
Navigate to Maven Project
cd $env:USERPROFILE\Desktop\testing-demo\calculator
2
Update azure-pipelines.yml
notepad azure-pipelines.yml
Replace with complete build + artifact pipeline:
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: Maven@3
displayName: 'Test with Coverage'
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean test'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
- task: PublishCodeCoverageResults@2
displayName: 'Publish Coverage'
inputs:
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/jacoco.xml'
codecoverageTool: 'JaCoCo'
- task: Maven@3
displayName: 'Package JAR'
inputs:
mavenPomFile: 'pom.xml'
goals: 'package -DskipTests'
- task: CopyFiles@2
displayName: 'Copy JAR Files'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: 'target/*.jar'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish JAR Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'calculator-jar'
publishLocation: 'Container'
Save and close
3
Commit and Push
git add azure-pipelines.yml
git commit -m "Add artifact publishing to pipeline"
git push
4
Monitor Pipeline Execution
- Go to Azure DevOps β Pipelines
- Watch pipeline execute
- See "Publish JAR Artifact" task complete β
5
View Published Artifact
- In pipeline run, click "Summary" tab
- Scroll to "Related" section
- See "1 published" under Artifacts
- Click artifact name: "calculator-jar"
- See files:
calculator-1.0-SNAPSHOT.jar
6
Download Artifact Manually
- Click "..." next to artifact name
- Select "Download artifacts"
- ZIP file downloads to your computer
- Extract and verify JAR file inside
β
Checkpoint: JAR artifact published and downloadable
Lab 2: Publish .NET Application Artifacts π·
Objective: Build and publish .NET application files
Time: 30 minutes
Exercise 2.1: Configure .NET Publish
1
Navigate to .NET Project
cd $env:USERPROFILE\Desktop\testing-demo\CalculatorApp
2
Update Pipeline for Artifacts
notepad azure-pipelines.yml
Complete .NET pipeline with artifacts:
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
displayName: 'Restore'
inputs:
command: 'restore'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Test'
inputs:
command: 'test'
arguments: '--configuration $(buildConfiguration) --collect:"XPlat Code Coverage"'
publishTestResults: true
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
codecoverageTool: 'Cobertura'
- task: DotNetCoreCLI@2
displayName: 'Publish Application'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'Calculator.Core/Calculator.Core.csproj'
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: 'Publish .NET Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'calculator-app'
publishLocation: 'Container'
Save and close
3
Push and Run Pipeline
git add .
git commit -m "Add .NET artifact publishing"
git push
4
View Published .NET Artifact
- Pipeline completes successfully
- Go to Summary β Artifacts section
- Click "calculator-app"
- See:
Calculator.Core.zip
- Download and extract to verify DLL files
β
Checkpoint: .NET application published as artifact
Lab 3: Versioning Artifacts π·οΈ
Objective: Add version numbers to artifacts
Time: 35 minutes
Exercise 3.1: Use Build Number for Versioning
1
Configure Build Number Format
notepad azure-pipelines.yml
Add at the top (before trigger):
name: $(Date:yyyyMMdd)$(Rev:.r)
trigger:
- main
2
Use Build Number in Artifact Name
Update the PublishBuildArtifacts task:
- task: PublishBuildArtifacts@1
displayName: 'Publish Versioned Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'calculator-$(Build.BuildNumber)'
publishLocation: 'Container'
3
Commit and Run
git add .
git commit -m "Add versioning to artifacts"
git push
4
Verify Versioned Artifacts
- Pipeline runs
- Check build number: e.g.,
20260217.1
- Artifact name:
calculator-20260217.1
- Each run creates uniquely named artifact
Exercise 3.2: Semantic Versioning
1
Update pom.xml Version
notepad pom.xml
Update version tag:
<groupId>com.example</groupId>
<artifactId>calculator</artifactId>
<version>1.0.0</version>
Change to: <version>1.1.0</version>
2
JAR Name Changes Automatically
- Maven uses version from pom.xml
- JAR will be named:
calculator-1.1.0.jar
- Commit, push, and verify
β
Checkpoint: Artifacts versioned automatically
Lab 4: Download and Use Artifacts π₯
Objective: Create deployment pipeline that downloads artifacts
Time: 30 minutes
Exercise 4.1: Create Deployment Pipeline
1
Create Deployment Pipeline File
cd $env:USERPROFILE\Desktop\testing-demo\calculator
notepad azure-pipelines-deploy.yml
2
Add Download and Deploy Steps
trigger: none
pool:
vmImage: 'windows-latest'
resources:
pipelines:
- pipeline: buildPipeline
source: 'calculator-build'
trigger: true
steps:
- task: DownloadBuildArtifacts@1
displayName: 'Download Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'calculator-jar'
downloadPath: '$(System.ArtifactsDirectory)'
- script: |
dir $(System.ArtifactsDirectory)
echo "Downloaded artifact successfully!"
displayName: 'List Artifact Contents'
- script: |
echo "Deploying JAR file..."
copy "$(System.ArtifactsDirectory)\calculator-jar\target\*.jar" "$(Build.ArtifactStagingDirectory)\"
echo "Deployment complete!"
displayName: 'Deploy Application'
Save and close
3
Commit Deployment Pipeline
git add azure-pipelines-deploy.yml
git commit -m "Add deployment pipeline"
git push
4
Create Deployment Pipeline in Azure DevOps
- Go to Pipelines β New Pipeline
- Select Azure Repos Git
- Choose your repository
- Select "Existing YAML file"
- Path:
/azure-pipelines-deploy.yml
- Click "Run"
5
Watch Download and Deploy
- Pipeline downloads artifact from build
- Lists files in artifact
- Simulates deployment
β
Checkpoint: Deployment pipeline downloads and uses artifacts
Lab 5: Publishing Multiple Artifacts π¦π¦
Objective: Publish different types of artifacts from single build
Time: 30 minutes
Exercise 5.1: Publish JAR, Documentation, and Test Results
1
Create Multi-Artifact Pipeline
notepad azure-pipelines.yml
Add multiple publish tasks:
- task: PublishBuildArtifacts@1
displayName: 'Publish Application'
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/target/*.jar'
ArtifactName: 'app'
- task: PublishBuildArtifacts@1
displayName: 'Publish Test Reports'
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/target/surefire-reports'
ArtifactName: 'test-reports'
- task: PublishBuildArtifacts@1
displayName: 'Publish Coverage Reports'
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/target/site/jacoco'
ArtifactName: 'coverage-reports'
2
Push and Verify
git add .
git commit -m "Publish multiple artifacts"
git push
3
View All Artifacts
- Pipeline completes
- Summary β Artifacts shows: "3 published"
- Click to expand and see all three:
- app (JAR file)
- test-reports (XML files)
- coverage-reports (HTML)
β
Checkpoint: Multiple artifacts published from single build
Lab 6: Explore Azure Artifacts π
Objective: Navigate and manage artifacts in Azure DevOps
Time: 20 minutes
Exercise 6.1: Navigate Artifacts
1
View All Artifacts
- Go to Pipelines β Runs
- Select any completed run
- Click "Summary" tab
- Scroll to "Related" β "Artifacts"
2
Download Artifact
- Click artifact name
- Click "..." (more options)
- Select "Download artifacts"
- ZIP downloads to Downloads folder
- Extract and explore contents
3
View Artifact Details
- Click artifact to expand
- See folder structure
- File sizes
- Upload timestamp
4
Compare Artifacts Across Builds
- Run pipeline multiple times (make small commits)
- View artifacts from different runs
- Compare sizes and contents
- Verify versioning works correctly
β
Checkpoint: Can navigate and download artifacts
Lab 7: Configure Retention Policies ποΈ
Objective: Set how long artifacts are kept
Time: 20 minutes
Exercise 7.1: View Default Retention
1
Access Retention Settings
- Go to Project Settings (bottom-left)
- Under Pipelines β Settings
- Find "Retention policies" section
2
Review Default Settings
Default retention typically:
- Builds: 30 days
- Releases: 365 days
- Artifacts: Deleted with build
3
Customize Retention (Optional)
- Click "Edit" or configure retention
- Set days to keep:
- Minimum: 7 days
- Maximum: 365 days
- Configure for different branches
- Save settings
Exercise 7.2: Retain Specific Builds
1
Retain a Build Indefinitely
- Go to specific pipeline run
- Click "..." (more options) in top-right
- Select "Retain run"
- Add reason (e.g., "Production release 1.0")
- This build and artifacts kept forever βΎοΈ
β
Checkpoint: Understand retention and how to keep important builds
π― Lab Summary
What You've Accomplished:
- β
Published Maven JAR artifacts
- β
Published .NET application artifacts
- β
Versioned artifacts using build numbers
- β
Created deployment pipeline with artifact download
- β
Published multiple artifacts from single build
- β
Navigated and downloaded artifacts
- β
Configured retention policies
Key Concepts Mastered:
- Artifacts: Build outputs (JAR, DLL, etc.)
- Publishing: Upload to Azure Artifacts
- Downloading: Retrieve for deployment
- Versioning: Track artifact versions
- Retention: Control artifact lifecycle
- Build Once, Deploy Many: Core DevOps principle
π Module 3 Complete!
You've mastered Testing & Artifacts in Azure DevOps!
π§ Troubleshooting Guide
| Issue |
Solution |
| No artifacts published |
Check PathtoPublish exists
Verify build created files (check target/ or bin/)
Review task logs for errors
|
| Artifact is empty |
Check file path pattern is correct
Use wildcard: target/*.jar
Verify files exist before publish task
|
| Download fails in deployment |
Verify artifact name matches exactly
Check build completed successfully
Ensure artifact wasn't deleted (retention)
|
| Wrong version in artifact |
Check pom.xml version for Maven
Verify .csproj version for .NET
Update build number format if using $(Build.BuildNumber)
|
| Artifact too large |
Exclude unnecessary files
Don't publish entire target/ directory
Use specific patterns: *.jar not **/*
|
π Quick Reference Commands
Maven Build:
mvn clean package
target\calculator-1.0-SNAPSHOT.jar
.NET Publish:
dotnet publish --configuration Release --output .\publish
publish\Calculator.Core.dll
publish\Calculator.Core.deps.json
Local Artifact Locations:
target\*.jar
target\surefire-reports\*
target\site\jacoco\*
bin\Release\net6.0\*.dll
publish\*
TestResults\*
Pipeline Variables:
$(Build.ArtifactStagingDirectory)
$(Build.BuildNumber)
$(System.DefaultWorkingDirectory)
$(System.ArtifactsDirectory)
π Day 14 Labs Complete!
You've successfully mastered artifact management!
Module 3: Testing & Artifacts - COMPLETE! β
π Skills Acquired:
- Build artifact creation (JAR, DLL)
- Publishing artifacts to Azure Artifacts
- Downloading artifacts in deployment pipelines
- Artifact versioning strategies
- Multiple artifact publishing
- Retention policy configuration
- Build once, deploy many principle
π Ready for Module 4!
Next: Release Management & Deployment Strategies