From the course: Intermediate Jenkins: Automate, Integrate, and Secure CI/CD Workflows at Scale

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Use secrets and credentials

Use secrets and credentials

When we're working with passwords, API keys, or other confidential details, Jenkins refers to that data as a secret or a credential. With that in mind, let's take a look at how Jenkins stores credentials and how we can use them safely and securely in a pipeline. Jenkins supports several types of credentials, including usernames and passwords, SSH keys, files, and text strings. Strings are particularly useful for values like API keys or security tokens. Pipelines can access credentials in several ways, but the two most common methods use the Credentials function and the WithCredentials build step. The Credentials function takes the ID of a secret stored in Jenkins as its argument and assigns the sensitive values to one or more environment variables. For most credential types, the function will return one value containing the sensitive information. However, when the Credentials function is used with a username and password credential, three variables are returned. The variable specified…

Contents