📖 Scenario: You are managing Jenkins credentials for a team. Some credentials should be available to all projects, while others should only be accessible within a specific folder to keep them secure.
🎯 Goal: Learn how to create and scope Jenkins credentials globally and within a folder, then verify their accessibility.
📋 What You'll Learn
Create a global credential in Jenkins
Create a folder-scoped credential in Jenkins
Access and list credentials in the global scope
Access and list credentials in a specific folder scope
💡 Why This Matters
🌍 Real World
In real Jenkins environments, credential scoping helps teams control who can access sensitive information like passwords or tokens, reducing security risks.
💼 Career
Understanding credential scoping is essential for Jenkins administrators and DevOps engineers to manage secrets securely and comply with best practices.
Progress0 / 4 steps
1
Create a global credential
Create a Jenkins credential with ID global-cred and description Global Credential in the global scope using the Jenkins CLI command jenkins-cli.jar. Use username admin and password admin123.
Jenkins
Hint
Use Jenkins CLI with an XML file defining the credential. The scope tag should be GLOBAL.
2
Create a folder-scoped credential
Create a Jenkins folder named ProjectFolder. Then create a credential with ID folder-cred and description Folder Credential scoped to ProjectFolder using Jenkins CLI and XML.
Jenkins
Hint
Create the folder first, then use the folder's credentials store path to add the credential with scope FOLDER.
3
List global credentials
Use Jenkins CLI to list all credentials in the global scope and verify that global-cred is present.
Jenkins
Hint
Use the Jenkins CLI list-credentials command with the global system scope.
4
List folder credentials
Use Jenkins CLI to list all credentials in the ProjectFolder folder scope and verify that folder-cred is present.
Jenkins
Hint
Use the Jenkins CLI list-credentials command with the folder scope path.
Practice
(1/5)
1. What does Global credential scope mean in Jenkins?
easy
A. The credential can be used by any job in Jenkins.
B. The credential is only available to jobs in a specific folder.
C. The credential is only available to the Jenkins administrator.
D. The credential expires after one use.
Solution
Step 1: Understand credential scopes
Global scope means credentials are accessible everywhere in Jenkins.
Step 2: Compare with folder scope
Folder scope limits credentials to jobs inside that folder only.
Final Answer:
The credential can be used by any job in Jenkins. -> Option A
Quick Check:
Global scope = accessible to all jobs [OK]
Hint: Global means all jobs can use it, no folder limits [OK]
Common Mistakes:
Confusing global with folder scope
Thinking global is admin-only
Assuming credentials expire automatically
2. Which of the following is the correct way to assign a credential to a folder in Jenkins?
easy
A. Add the credential under Jenkins > Credentials > System > Global credentials
B. Add the credential inside the folder's Credentials section
C. Add the credential in the job configuration only
D. Add the credential in Jenkins > Manage Plugins
Solution
Step 1: Locate folder credentials
Folder scoped credentials are added inside the folder's own Credentials section.
Step 2: Differentiate from global credentials
Global credentials are added under Jenkins system credentials, not folder.
Final Answer:
Add the credential inside the folder's Credentials section -> Option B
Quick Check:
Folder credentials go inside folder settings [OK]
Hint: Folder credentials must be added inside that folder [OK]
Common Mistakes:
Adding folder credentials to global system store
Trying to add credentials in job config only
Confusing plugin management with credentials
3. Given a folder named ProjectA with a credential scoped to it, what happens if a job outside ProjectA tries to use that credential?
medium
A. The job can use the credential without restrictions.
B. The job will use a default global credential instead.
C. The job will fail to access the credential.
D. The job will prompt the user to enter the credential manually.
Solution
Step 1: Understand folder scope restrictions
Folder scoped credentials are only accessible to jobs inside that folder.
Step 2: Check job location
A job outside the folder cannot access folder-scoped credentials.
Final Answer:
The job will fail to access the credential. -> Option C
Quick Check:
Folder scope blocks jobs outside folder [OK]
Hint: Folder credentials block jobs outside folder [OK]
Common Mistakes:
Assuming folder credentials are global
Thinking Jenkins auto-fills missing credentials
Believing jobs can prompt for credentials
4. You added a credential to a folder but jobs inside the folder still cannot access it. What is the most likely cause?
medium
A. The folder permissions prevent jobs from using credentials.
B. The jobs are not inside the folder where the credential was added.
C. The credential was added with global scope instead of folder scope.
D. The credential type is unsupported by Jenkins.
Solution
Step 1: Verify credential scope
If credential is in folder, scope is correct; global scope would make it accessible everywhere.
Step 2: Check folder permissions
Folder permissions can restrict job access to credentials even if scope is correct.
Final Answer:
The folder permissions prevent jobs from using credentials. -> Option A
Quick Check:
Permissions can block credential use inside folder [OK]
Hint: Check folder permissions if folder credentials fail [OK]
Common Mistakes:
Assuming scope is wrong without checking permissions
5. You want to restrict a credential so only jobs in the DevOps folder and its subfolders can use it, but not jobs elsewhere. How should you configure the credential?
hard
A. Add the credential in each job configuration inside DevOps.
B. Add the credential with global scope and restrict job permissions manually.
C. Add the credential with system scope to limit access.
D. Add the credential with folder scope inside the DevOps folder.
Solution
Step 1: Understand folder scope for restriction
Folder scope limits credential use to jobs inside that folder and its subfolders.
Step 2: Avoid global or system scope
Global scope allows all jobs; system scope is not a valid Jenkins credential scope.
Step 3: Avoid per-job credentials for manageability
Adding credentials per job is inefficient and error-prone.
Final Answer:
Add the credential with folder scope inside the DevOps folder. -> Option D
Quick Check:
Folder scope limits credential to folder and subfolders [OK]
Hint: Use folder scope inside DevOps folder for restriction [OK]
Common Mistakes:
Using global scope and relying on permissions only
Confusing system scope with folder scope
Adding credentials individually to jobs
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.