Certified Jenkins Engineer
Jenkins Administration and Monitoring Part 1
Demo Jenkins Folder Part 3
In this guide, you’ll learn how to clone an existing Jenkins folder configuration—team-a—to a new folder named team-c. By copying the folder, Team C automatically inherits pipelines, credentials, and settings from Team A, ensuring consistency and reducing setup time.
Table of Contents
- Creating the Team C Folder
- Verifying the Copied Pipelines
- Accessing Inherited Credentials
- Triggering and Viewing the Build
- Sample Console Output
- References
Creating the Team C Folder
- In Jenkins, click New Item.
- Enter team-c for the folder name.
- Select Folder as the item type.
- Under Copy from, search for and choose team-a.
- Click OK to confirm.
Jenkins will replicate all projects, credentials, and folder-level settings from team-a into team-c.
Note
Copied folder items (jobs) inherit the disabled state. You must manually enable them before running builds.
Verifying the Copied Pipelines
Navigate into the newly created team-c folder. You should see team-a-pipeline listed—this confirms the pipeline configuration has been cloned successfully.
Open the pipeline’s Configure view and compare it to Team A’s pipeline to ensure all stages and steps match.
Accessing Inherited Credentials
Since team-c inherits from team-a, it also has access to both the Shared Infrastructure credentials and the Team A credentials. Verify under Credentials → team-c → shared-infrastructure.
In your Jenkinsfile
, use a withCredentials
block to bind these credentials to environment variables:
pipeline {
agent any
stages {
stage('Accessing Credentials') {
steps {
withCredentials([
usernamePassword(
credentialsId: 'shared-db-creds-id',
usernameVariable: 'SHARED_DB_USR',
passwordVariable: 'SHARED_DB_PSW'
),
usernamePassword(
credentialsId: 'team-a-creds-id',
usernameVariable: 'TEAM_A_USR',
passwordVariable: 'TEAM_A_PSW'
)
]) {
script {
echo "Shared DB Username: ${SHARED_DB_USR}"
echo "Team A Username: ${TEAM_A_USR}"
}
}
}
}
}
post {
success { echo "Build completed successfully" }
failure { echo "Build failed" }
}
}
Credentials Reference Table
Credential ID | Bound Variables | Purpose |
---|---|---|
shared-db-creds-id | SHARED_DB_USR<br>SHARED_DB_PSW | Shared infrastructure database access |
team-a-creds-id | TEAM_A_USR<br>TEAM_A_PSW | Team A-specific secrets |
Triggering and Viewing the Build
- Inside team-c, open team-a-pipeline → Configure and click Save to enable the job.
- Click Build Now on the pipeline page.
- Monitor the progress: each stage, including “Start,” “Accessing Credentials,” and “Post Actions,” should complete successfully.
Sample Console Output
Started by user siddharth
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/shared-infrastructure/team-c/team-a-pipeline
[Pipeline] withCredentials
Masking supported pattern matches of $TEAM_A_USR or $TEAM_A_PSW or $SHARED_DB_USR or $SHARED_DB_PSW
[Pipeline] stage
[Pipeline] { (Accessing Credentials)
[Pipeline] script
[Pipeline] echo
Shared DB Username: shared-DATABASE-username
[Pipeline] echo
Team A Username: team-AAAAA-username
[Pipeline] }
[Pipeline] // script
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Build completed successfully
[Pipeline] }
By cloning team-a into team-c, you ensure all pipelines, credentials, and folder-level configurations are inherited, streamlining setup for new teams and maintaining organizational standards.
References
Watch Video
Watch video content