Credentials in Jenkins store sensitive information like passwords, tokens, or keys securely to allow Jenkins jobs to access external systems without exposing secrets.
Click to reveal answer
beginner
Name three common types of credentials supported by Jenkins.
Jenkins supports Username and Password, Secret Text, and SSH Username with Private Key as common credential types.
Click to reveal answer
intermediate
How does Jenkins store credentials securely?
Jenkins encrypts credentials and stores them in its internal credentials store, which is protected by Jenkins' security settings and file system permissions.
Click to reveal answer
intermediate
What is the difference between 'Secret Text' and 'Username and Password' credential types in Jenkins?
'Secret Text' stores a single secret string like an API token, while 'Username and Password' stores a pair of username and password for authentication.
Click to reveal answer
intermediate
Where can Jenkins credentials be scoped to control their availability?
Credentials in Jenkins can be scoped globally (available to all jobs) or to specific folders or pipelines to limit access.
Click to reveal answer
Which Jenkins credential type would you use to store an SSH private key?
ACertificate
BSecret Text
CUsername and Password
DSSH Username with Private Key
✗ Incorrect
The 'SSH Username with Private Key' credential type is designed specifically to store SSH private keys for authentication.
Where are Jenkins credentials stored?
AIn environment variables only
BIn plain text files on the Jenkins server
CEncrypted in Jenkins internal credentials store
DOn the user's local machine
✗ Incorrect
Jenkins encrypts credentials and stores them securely in its internal credentials store on the server.
What is the main benefit of scoping credentials in Jenkins?
ATo limit credential access to specific jobs or folders
BTo speed up Jenkins builds
CTo make credentials available to all users
DTo store credentials in plain text
✗ Incorrect
Scoping credentials limits their availability to specific jobs or folders, improving security by reducing exposure.
Which credential type is best for storing an API token in Jenkins?
AUsername and Password
BSecret Text
CSSH Username with Private Key
DCertificate
✗ Incorrect
Secret Text is used to store single secret strings like API tokens.
Can Jenkins credentials be shared between different pipelines?
AYes, if credentials are scoped globally or to a shared folder
BNo, credentials are always private to one pipeline
COnly if stored in environment variables
DOnly if manually copied
✗ Incorrect
Credentials scoped globally or to a shared folder can be accessed by multiple pipelines.
Explain the different types of credentials Jenkins supports and when to use each.
Think about what kind of secret you need to store and how Jenkins uses it.
You got /4 concepts.
Describe how Jenkins stores credentials securely and how scoping affects their availability.
Consider both storage and access control.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is NOT a common Jenkins credential type?
easy
A. Database connection string
B. Secret text
C. SSH private key
D. Username and password
Solution
Step 1: Review common Jenkins credential types
Jenkins commonly uses username/password, secret text, SSH keys, and secret files as credential types.
Step 2: Identify the option not listed as a credential type
Database connection string is not a built-in Jenkins credential type; it can be stored as secret text but is not a distinct type.
sshUserPrivateKey requires both credentialsId and usernameVariable to bind the SSH username.
Step 2: Identify missing usernameVariable
The snippet only uses keyFileVariable but misses usernameVariable, which is required for proper binding.
Final Answer:
Missing usernameVariable in sshUserPrivateKey binding -> Option D
Quick Check:
sshUserPrivateKey needs usernameVariable and keyFileVariable [OK]
Hint: sshUserPrivateKey needs usernameVariable and keyFileVariable [OK]
Common Mistakes:
Omitting usernameVariable in sshUserPrivateKey
Thinking keyFileVariable alone is enough
Believing sh cannot use env variables
5. You want to securely use a secret file credential in a Jenkins pipeline to deploy a configuration file. Which is the correct way to access the secret file inside the pipeline?
hard
A. Use credentials('config-file') directly in the shell command
B. Use withCredentials([string(credentialsId: 'config-file', variable: 'CONFIG')]) and echo $CONFIG
C. Use withCredentials([file(credentialsId: 'config-file', variable: 'CONFIG')]) and refer to $CONFIG path
D. Store the file content as secret text and write it manually in the pipeline
Solution
Step 1: Understand secret file credential usage
Secret files are accessed by binding them to a file path variable using file() in withCredentials.
Step 2: Use the file path variable in pipeline steps
The variable (e.g., CONFIG) holds the path to the secret file, which can be used in shell commands safely.
Final Answer:
Use withCredentials([file(credentialsId: 'config-file', variable: 'CONFIG')]) and refer to $CONFIG path -> Option C
Quick Check:
Secret files bind to file path variables with file() [OK]
Hint: Use file() binding for secret files to get file path [OK]
Common Mistakes:
Using string() for secret files instead of file()
Trying to use credentials() directly in shell
Manually writing file content instead of binding
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.