0
0
Jenkinsdevops~30 mins

Artifact fingerprinting in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
Artifact Fingerprinting in Jenkins
📖 Scenario: You are working as a DevOps engineer managing a Jenkins pipeline for a software project. You want to track and verify the artifacts produced by your builds to ensure consistency and traceability.Artifact fingerprinting helps Jenkins record unique identifiers (hashes) for files created during builds. This way, you can trace which build produced which artifact and detect if artifacts are reused or changed.
🎯 Goal: Build a simple Jenkins pipeline script that enables artifact fingerprinting for a specific file. You will create a file, configure fingerprinting, and then print the fingerprint information.
📋 What You'll Learn
Create a file named app.jar with sample content
Enable fingerprinting for the app.jar artifact
Use Jenkins pipeline syntax to record the fingerprint
Print the fingerprint details in the build log
💡 Why This Matters
🌍 Real World
Artifact fingerprinting is used in real Jenkins pipelines to track build outputs and ensure traceability of files across builds and deployments.
💼 Career
Understanding artifact fingerprinting helps DevOps engineers maintain build integrity and troubleshoot issues related to artifact reuse or corruption.
Progress0 / 4 steps
1
Create the artifact file
Create a file named app.jar with the exact content Sample artifact content using the sh step in the Jenkins pipeline.
Jenkins
Need a hint?

Use the sh step with an echo command to create the file app.jar with the exact text.

2
Enable artifact fingerprinting
Add a fingerprint step inside the Create Artifact stage to fingerprint the file app.jar.
Jenkins
Need a hint?

Use the fingerprint step with the exact string 'app.jar' to enable fingerprinting.

3
Retrieve fingerprint information
Add a script block inside the Create Artifact stage steps to get the fingerprint information for app.jar using currentBuild.rawBuild.getFingerprint('app.jar') and store it in a variable called fp.
Jenkins
Need a hint?

Use a script block and assign currentBuild.rawBuild.getFingerprint('app.jar') to a variable named fp.

4
Print fingerprint details
Inside the same script block, add a println statement to print the fingerprint hash using fp.getHashString().
Jenkins
Need a hint?

Use println with the exact string Fingerprint hash: ${fp.getHashString()} to display the fingerprint.