πŸ“¦ Day 14: Test Reporting & Artifacts - Hands-On Lab Guide

Practical exercises for publishing and managing build artifacts (Windows Edition)

Duration: 4 hours | Module: Testing & Artifacts

πŸ’» Windows Environment: All commands optimized for Windows PowerShell.
⚠️ Prerequisites Check:
  1. Days 12-13 complete (tests and coverage working)
  2. Maven and .NET projects from previous days
  3. Azure Pipeline configured and running
  4. 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
# Open your calculator project cd $env:USERPROFILE\Desktop\testing-demo\calculator
2 Update azure-pipelines.yml
notepad azure-pipelines.yml

Replace with complete build + artifact pipeline:

# Maven Build with Artifact Publishing trigger: - main pool: vmImage: 'windows-latest' variables: buildConfiguration: 'Release' steps: # Run tests with coverage - task: Maven@3 displayName: 'Test with Coverage' inputs: mavenPomFile: 'pom.xml' goals: 'clean test' publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' # Publish coverage - task: PublishCodeCoverageResults@2 displayName: 'Publish Coverage' inputs: summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/jacoco.xml' codecoverageTool: 'JaCoCo' # Package application - task: Maven@3 displayName: 'Package JAR' inputs: mavenPomFile: 'pom.xml' goals: 'package -DskipTests' # Copy JAR to staging directory - task: CopyFiles@2 displayName: 'Copy JAR Files' inputs: SourceFolder: '$(System.DefaultWorkingDirectory)' Contents: 'target/*.jar' TargetFolder: '$(Build.ArtifactStagingDirectory)' # Publish artifact - 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:

# .NET Build with Artifact Publishing trigger: - main pool: vmImage: 'windows-latest' variables: buildConfiguration: 'Release' steps: # Restore - task: DotNetCoreCLI@2 displayName: 'Restore' inputs: command: 'restore' # Build - task: DotNetCoreCLI@2 displayName: 'Build' inputs: command: 'build' arguments: '--configuration $(buildConfiguration)' # Test with coverage - task: DotNetCoreCLI@2 displayName: 'Test' inputs: command: 'test' arguments: '--configuration $(buildConfiguration) --collect:"XPlat Code Coverage"' publishTestResults: true # Publish coverage - task: PublishCodeCoverageResults@2 inputs: summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' codecoverageTool: 'Cobertura' # Publish application files - 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 # Upload artifact to Azure DevOps - 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):

# Custom build number format name: $(Date:yyyyMMdd)$(Rev:.r) # Result: 20260217.1, 20260217.2, etc. 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
# Deployment Pipeline (downloads artifact from build) trigger: none # Manual trigger only pool: vmImage: 'windows-latest' resources: pipelines: - pipeline: buildPipeline source: 'calculator-build' # Name of your build pipeline trigger: true # Auto-trigger on successful build steps: # Download build artifact - task: DownloadBuildArtifacts@1 displayName: 'Download Artifact' inputs: buildType: 'current' downloadType: 'single' artifactName: 'calculator-jar' downloadPath: '$(System.ArtifactsDirectory)' # List downloaded files - script: | dir $(System.ArtifactsDirectory) echo "Downloaded artifact successfully!" displayName: 'List Artifact Contents' # Simulate deployment - 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:

# After your build and test tasks... # Artifact 1: Application JAR - task: PublishBuildArtifacts@1 displayName: 'Publish Application' inputs: PathtoPublish: '$(System.DefaultWorkingDirectory)/target/*.jar' ArtifactName: 'app' # Artifact 2: Test Reports - task: PublishBuildArtifacts@1 displayName: 'Publish Test Reports' inputs: PathtoPublish: '$(System.DefaultWorkingDirectory)/target/surefire-reports' ArtifactName: 'test-reports' # Artifact 3: Coverage 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:

  1. Artifacts: Build outputs (JAR, DLL, etc.)
  2. Publishing: Upload to Azure Artifacts
  3. Downloading: Retrieve for deployment
  4. Versioning: Track artifact versions
  5. Retention: Control artifact lifecycle
  6. 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:

# Build JAR file mvn clean package # JAR location target\calculator-1.0-SNAPSHOT.jar

.NET Publish:

# Publish application dotnet publish --configuration Release --output .\publish # Published files publish\Calculator.Core.dll publish\Calculator.Core.deps.json

Local Artifact Locations:

# Maven artifacts target\*.jar # JAR files target\surefire-reports\* # Test results target\site\jacoco\* # Coverage reports # .NET artifacts bin\Release\net6.0\*.dll # Build output publish\* # Published files TestResults\* # Test results

Pipeline Variables:

# Useful for artifact publishing $(Build.ArtifactStagingDirectory) # Temp folder for artifacts $(Build.BuildNumber) # Build number (for versioning) $(System.DefaultWorkingDirectory) # Source code directory $(System.ArtifactsDirectory) # Downloaded artifacts location

πŸŽ‰ 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