0
0
Jenkinsdevops~15 mins

Library directory structure in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
Library Directory Structure in Jenkins
šŸ“– Scenario: You are setting up a Jenkins shared library to reuse common pipeline code across multiple projects. This library will have a specific directory structure that Jenkins expects.
šŸŽÆ Goal: Build the basic directory structure for a Jenkins shared library with folders for vars and src, and add a simple Groovy script in vars.
šŸ“‹ What You'll Learn
Create a root directory named my-shared-library
Inside it, create a vars directory
Inside vars, create a Groovy file named hello.groovy with a simple function
Create a src directory inside the root directory
šŸ’” Why This Matters
šŸŒ Real World
Jenkins shared libraries help teams reuse pipeline code easily, making CI/CD pipelines cleaner and easier to maintain.
šŸ’¼ Career
Understanding the Jenkins shared library structure is essential for DevOps engineers to create scalable and maintainable automation pipelines.
Progress0 / 4 steps
1
Create the root directory and vars folder
Create a directory named my-shared-library and inside it create another directory named vars.
Jenkins
Need a hint?

Use commands like mkdir -p my-shared-library/vars to create nested directories.

2
Add a Groovy script in vars folder
Inside the vars directory, create a file named hello.groovy with this exact content:
def call() { echo 'Hello from shared library!' }
Jenkins
Need a hint?

Use a text editor or echo command to create the file with the exact function.

3
Create the src directory
Inside the my-shared-library directory, create a directory named src.
Jenkins
Need a hint?

Use mkdir my-shared-library/src to create the src folder.

4
Display the directory structure
Use a command to display the full directory structure of my-shared-library showing vars/hello.groovy and src folders.
Jenkins
Need a hint?

Use the tree command or ls -R to show the directory structure.