Which Jenkins credential type is best suited to store a username and password pair securely?
Think about which type explicitly stores both username and password together.
The 'Username with password' credential type is designed to securely store a username and its associated password. Other types store different secrets like text, SSH keys, or certificates.
What is the output of the following Jenkins CLI command when listing credentials in a folder named 'projectA'?
java -jar jenkins-cli.jar -s http://jenkins.example.com/ list-credentials projectA
Assume the folder 'projectA' contains two credentials: one username/password and one secret text.
The command lists all credentials in the specified folder. Since 'projectA' has two credentials, the output shows both with their ids, types, and descriptions.
Which Jenkinsfile snippet correctly uses the 'usernamePassword' credentials binding to inject username and password environment variables?
Look for the correct use of withCredentials and variable names for username and password.
Option D correctly uses withCredentials with usernamePassword binding and defines separate variables for username and password. Other options misuse environment or credential types.
A Jenkins pipeline fails with the error: java.lang.IllegalArgumentException: No credentials found with id 'deploy-key'. What is the most likely cause?
Consider where credentials are stored and their scope in Jenkins.
This error usually means Jenkins cannot find the credential with the given id in the current folder or global credentials store. It is a scope or existence issue, not network or syntax.
Which is the most secure and recommended way to store and use API tokens in Jenkins pipelines?
Think about avoiding exposure of secrets and following Jenkins best practices.
Storing API tokens as 'Secret text' credentials and injecting them securely during pipeline execution prevents exposure in code or logs. Hardcoding or storing in files is insecure. Using username/password with empty username is not appropriate.