The Credentials Store (Basic) in Jenkins
A friendly, step-by-step guide to the built-in safe where Jenkins keeps passwords, tokens, keys, and files, and how builds borrow them without ever showing them to the world.
Imagine a hotel. Guests come and go all day, and many of them need keys: keys to rooms, to the gym, to the storage room. The hotel does not hand every guest a big ring of master keys. Instead, all keys stay in a locked cabinet behind the front desk. When a guest needs a key, the receptionist hands over the one key that guest is allowed to use, and takes it back afterwards. Nobody wanders off with the whole cabinet.
Jenkins has the same problem. Builds must log in to code repositories, upload packages, and deploy to servers. All of that needs secrets: passwords, tokens, and keys. If every developer types secrets straight into their job settings, the secrets end up scattered everywhere, visible to anyone who looks. Jenkins solves this with a locked cabinet of its own, called the credentials store. In this guide you will learn what it is, what it can hold, how it protects secrets, how builds use them safely, who is allowed to see and change them, and what habits keep the whole thing secure. No earlier knowledge is needed, and every new word is explained the first time it appears.
1What Is the Credentials Store?
The credentials store is the built-in, encrypted safe inside Jenkins where secrets are kept, so that jobs can use them by name without ever seeing or printing them.
Start with the word credential. A credential is anything you use to prove who you are: a username and password, a secret token, a private key, or a certificate. When a person logs in to a website, they present a credential. When Jenkins logs in to a code repository or a server, it must present one too.
The credentials store is where Jenkins keeps these credentials. It comes from a core plugin called the Credentials plugin, which is installed with almost every Jenkins. The word “basic” in this guide’s title refers to the standard, built-in kind of store and the basic credential types that come with it, as opposed to advanced setups that connect Jenkins to an outside secrets service.
The big idea: use by name, not by value
When you save a secret in the store, you give it an ID, a short name such as “shop-deploy-key”. From then on, jobs never mention the secret itself. They only say, “Please use the credential called shop-deploy-key.” Jenkins looks up the real secret, hands it to the build at the right moment, and hides it from the log. The secret lives in one place, and everybody else only knows its nickname.
Think of a valet parking desk. You do not give the whole car park your car keys. You give one key to the valet, who brings your car when you show your ticket. Your ticket number is like the credential ID: it points to the key without being the key.
2Why Jenkins Needs a Credentials Store
Without a safe, secrets leak. It is only a matter of time.
Think about what Jenkins does all day. It downloads private code, pushes finished packages to storage, deploys software to real servers, and sends messages through mail and chat services. Every one of these actions needs a secret. Before credentials stores existed, teams often pasted secrets directly into the places where they were needed. That caused several troubles.
Secrets in plain sight
A password typed into a job setting or a script can be read by anyone who can view that job, and it appears in backups and copies.
Secrets in the log
A command that prints its own settings can write the password into the build log, where many people can read it.
Secrets in the repository
A secret placed in a file in the code repository is copied to every computer that clones it, and stays in history forever.
Painful changes
When a password must be changed, someone has to hunt through dozens of jobs to update every copy. Miss one, and builds start failing.
The credentials store fixes all four. There is one encrypted home for every secret. Jobs refer to it by name. Jenkins hides the values in logs. And changing a secret means editing one entry, and every job that uses it picks up the new value automatically.
A simple test for a healthy setup: search all your job settings and repositories for the word “password”. If you find real passwords, they belong in the credentials store instead.
3Core Concepts You Must Know
A handful of words unlock everything about the credentials store. Learn these and the rest feels natural.
Credential
Any secret used to prove identity: a password, token, key, or certificate.
Store
A place where credentials are kept. Jenkins has a main store, and folders and users can have their own.
Credential ID
The unique nickname of a credential. Jobs refer to this ID, never to the secret itself.
Description
A human-friendly explanation of what the credential is for and who owns it. Very helpful later.
Scope
Decides where a credential may be used. The two basic scopes are Global and System.
Domain
A way to group credentials by the website or service they are meant for, so Jenkins offers them only where they make sense.
Encryption
Scrambling data so it is unreadable without a secret key. Jenkins encrypts every stored secret.
Binding
The act of lending a credential to a build for a short time, as a temporary variable or file.
Masking
Replacing a secret with stars in the build log so it cannot be read.
Permission
What a person may do with credentials: view, create, change, or delete them.
Controller
The central Jenkins server. It holds the store, the encryption keys, and the settings.
Agent
A machine that runs builds. It receives secrets from the controller only for the moment they are needed.
Where do you find the store?
Administrators open the Jenkins menu called Manage Jenkins and choose Credentials, which sits among the security-related options. There you see the stores available, the domains inside them, and the credentials themselves. Each credential appears as a row with its name, kind, ID, and description. The secret value itself is never shown again after you save it. You may replace it, but you cannot read it back.
4The Basic Credential Types
Not all secrets look alike. Jenkins offers a few basic shapes, each fitting a different need.
| Type | What it holds | Typical use |
|---|---|---|
| Username with password | A username and a password, stored together | Logging in to a code repository, a package storage, or a website |
| Secret text | One single secret string, such as an access token or an API key | Calling a web service, or a personal access token for a code host |
| Secret file | An entire file that must stay private | A configuration file that holds keys, or a service account file |
| SSH username with private key | A username and a private SSH key, with an optional passphrase | Connecting to servers and code repositories over SSH |
| Certificate | A certificate bundle, with its own password | Signing programs, or connecting to services that require certificate login |
Understanding each type in plain words
Username with password
The most familiar type. It stores two things together: who you are and your secret. Many code hosts no longer accept a person’s real account password for automation, so this type is often used with a token in the password position. Jenkins can hand a build both values, either as two separate temporary variables or as one combined value.
Secret text
A single hidden string. It is perfect for tokens, which are long random strings that act like a password with limited powers. A token can usually be narrow, such as “read only” or “can only upload packages”, and can be cancelled easily if it leaks.
Secret file
Sometimes the secret is not a short string but a whole file. Jenkins stores the file encrypted. When a build needs it, Jenkins writes it to a temporary spot on the agent, tells the build where it is, and removes it when the work is done.
SSH username with private key
SSH is a secure way to log in to another computer. It uses a pair of matching digital keys: a public half that is placed on the target server, and a private half that must stay secret. This credential holds the private half, plus a username. The private key can be pasted in directly. Some setups can read a key from a file on the controller, but pasting into the store is the safer, clearer choice, because it keeps the secret inside the encrypted store.
Certificate
A certificate is a digital identity card. In Jenkins, this type holds a certificate bundle protected by its own password, and is used when a service asks the caller to prove identity with a certificate rather than a password.
Think of the different ways a person can enter buildings. A username and password is like a name badge with a PIN. A token is like a visitor sticker that expires. A secret file is like a sealed envelope handed at the gate. An SSH key is like a personal metal key that fits only one lock. A certificate is like an official ID card checked by a guard.
Plugins can add more credential types, such as cloud provider keys or tokens for specific services. The five types above are the basic set that most teams meet first.
5Architecture: How the Store Works
Let us look at how the pieces fit together, from a saved secret to a running build.
Jenkins has one controller, the brain, and many agents, the workers. The credentials store lives on the controller. When an administrator saves a credential, the controller encrypts it and writes it to its storage folder, called JENKINS_HOME. When a build needs the credential, the controller decrypts it in memory, sends it to the agent for just that build, and the agent uses it and forgets it.
flowchart LR
ADM["Administrator"] -->|"saves secret"| UI["Jenkins Web Interface"]
UI --> CTRL["Jenkins Controller"]
CTRL -->|"encrypt"| ENC["Encryption Keys in secrets folder"]
CTRL -->|"write encrypted value"| STORE[("Credentials Store in JENKINS_HOME")]
JOB["Job or Pipeline"] -->|"asks for credential by ID"| CTRL
CTRL -->|"check permission and scope"| STORE
STORE -->|"decrypt in memory"| CTRL
CTRL -->|"temporary secret for one build"| AGT["Build Agent"]
AGT -->|"uses secret"| TARGET["Repository, Server, or Service"]
AGT -->|"masked log"| LOG["Build Log"]
Walking through the picture
An administrator saves a secret through the Jenkins web interface. The controller encrypts it using keys kept in a protected folder and writes only the encrypted form into the store. Later, a job asks for the credential by its ID. The controller checks that the job is allowed to use it, decrypts it in memory, and hands a temporary copy to the agent running that build. The agent uses the secret to reach the target, such as a repository or server, and Jenkins masks the value in the build log. When the build ends, the temporary copy is thrown away.
The three kinds of stores
System store
The main store of the whole Jenkins server. Administrators manage it, and it holds the credentials most jobs share.
Folder store
Each folder of jobs can have its own store. Credentials placed there are usable only by jobs inside that folder, which keeps teams apart.
User store
Each person can keep credentials of their own, which are usable only in that person’s own context.
Do not confuse the credentials store with the code repository. Secrets belong in the store on the controller, never in files that live beside your code.
6Scopes and Domains: Controlling Where a Secret Works
Not every secret should be usable everywhere. Scopes and domains draw the boundaries.
Scope: who may use the credential?
Every credential has a scope that decides where it can be used. The two basic scopes are described below.
Global scope
- Usable by jobs and pipelines, and by Jenkins itself
- The everyday choice for secrets that builds need
- Any job that knows the ID and has access can use it
System scope
- Meant only for Jenkins itself, such as mail server logins and agent connections
- Not available to jobs and pipelines
- Protects infrastructure secrets from being borrowed by a build
This split matters. The password that Jenkins uses to send emails or to connect to an agent should not be something a random job can grab. By giving such credentials system scope, you keep them out of reach of pipeline scripts, so a careless or malicious job cannot read them.
Domains: matching secrets to places
A domain is a group of credentials tied to a certain service or website. For example, you may create a domain for one particular code host, and place its credentials inside. Jenkins then offers those credentials only where a matching address is used. Domains keep long lists tidy and prevent accidentally sending a secret to the wrong service.
| Setting | Question it answers | Example |
|---|---|---|
| Store | Where is the credential kept? | Main store, one team’s folder, or one user’s own space |
| Scope | Who or what may use it? | Global for jobs, System for Jenkins itself |
| Domain | Which service is it meant for? | A domain for one code host’s addresses |
| Permission | Which people may manage it? | Only administrators may change; developers may only use |
In an office building, the master key for the electrical room is kept by the building manager (system scope). The key to a team’s meeting room is held by that team (folder store). The general visitor pass works at the front door for many people (global scope). Each key opens only what it is meant to open.
Place team-specific secrets in the team’s folder store, and keep the main store for secrets truly shared by everyone. Smaller circles of trust mean smaller damage if something leaks.
7Adding a Credential Step by Step
Creating a credential takes only a minute. Here is the journey in plain steps.
Open the credentials page
Choose Manage Jenkins, then Credentials. Pick the store and domain where the new credential should live, or the folder of the team that will use it.
Choose Add Credentials
A form opens, and the first choice is the kind of credential: username with password, secret text, secret file, SSH key, or certificate.
Choose the scope
Pick Global for secrets that jobs need, or System for secrets used only by Jenkins itself.
Enter the secret
Type or paste the secret value, or upload the file. The field hides what you type, and once saved, the value can never be shown again.
Give it an ID
Choose a clear, meaningful ID such as “shop-registry-token”. If you leave it blank, Jenkins makes up a random one that is hard to remember. IDs are used in job settings, so pick a good name from the start, since it usually cannot be changed later.
Write a description
Say what the credential is for, what account it belongs to, and when it expires. Future you will be grateful.
Save and test
Save the entry, then try it in a real job or with a connection test button where one is offered.
Naming credential IDs well
A good ID answers three questions at a glance: what service, what purpose, and what level of access. For example, “codehost-readonly-token” tells you much more than “cred1”. Consistent names across the company let people find the right credential without asking, and reduce the risk of picking the wrong one.
The secret value is write-only. You can replace it with a new one at any time, but you cannot read the old one back. If you lose a secret, get a fresh one from its original source, such as the code host or the cloud provider.
8How Builds Use Credentials
Saving a secret is only half the story. The other half is lending it to a build safely.
Three common ways a job uses a credential
Picked from a list
Many settings, such as the repository login in the source code section of a job, offer a drop-down list of credentials. You just pick one by name. Jenkins does the rest.
Bound to variables
A job can ask Jenkins to bind a credential to a temporary variable, so build steps can read it from the environment. Jenkins supplies the value only while those steps run.
Named in the pipeline
A pipeline refers to the credential ID in its text file, and Jenkins fetches the value at run time. The secret itself never appears in the file.
The feature that makes binding possible comes from the Credentials Binding plugin. It lets a job say, “For these steps only, make this credential available as a variable.” When the steps end, the variable disappears.
What binding looks like for each type
| Credential type | What the build receives |
|---|---|
| Secret text | One temporary variable holding the secret string |
| Username with password | Two temporary variables, one for the username and one for the password, or one combined variable |
| Secret file | A temporary file on the agent, plus a variable that holds its location |
| SSH key | A temporary key file, with variables for its location, username, and passphrase |
| Certificate | A temporary certificate file, with variables for its location and password |
sequenceDiagram participant J as Pipeline participant C as Jenkins Controller participant S as Credentials Store participant A as Build Agent participant T as Target Service J->>C: Use credential by ID C->>S: Check permission and scope S-->>C: Return decrypted secret in memory C->>A: Send secret for this block only A->>T: Log in or call service with secret A-->>C: Return output with secret masked C->>A: Remove temporary secret after block ends
The lending is short and narrow
Notice the pattern: the secret exists on the agent only for the small block of work that needs it. This is the principle of least exposure. Wrap the credential around only the steps that truly need it, not the whole pipeline. If a build has ten stages and only the last one deploys, only the last one should ever see the deployment password.
A library lends a book for two weeks. The reader uses it, then returns it. The library does not give the book away, and it knows exactly who has it. Binding a credential is a short loan, not a gift.
9How Jenkins Protects Stored Secrets
Encryption is the heart of the store’s safety. Let us see how it works in simple terms.
When you save a secret, Jenkins does not write the readable value to disk. It first scrambles the value using an encryption key. Only someone who holds the right key can unscramble it. Jenkins keeps its encryption keys in a protected folder, called the secrets folder, inside JENKINS_HOME. The scrambled credentials themselves are kept in a separate settings file.
So there are two ingredients that must be together to recover a secret: the encrypted data, and the keys. An attacker who steals only one of them learns almost nothing. An attacker who steals both can read every secret.
flowchart LR
SECRET["Plain Secret"] -->|"encrypt with key"| ENC["Encrypted Value"]
KEYS[("Encryption Keys in secrets folder")] --> ENC
ENC --> FILE[("Credentials Settings File")]
FILE -->|"read at build time"| DEC["Decrypt in Memory"]
KEYS --> DEC
DEC --> USE["Short Loan to One Build"]
What masking does, and what it does not
While a build runs, Jenkins watches its log. If a bound secret appears in the output, Jenkins replaces it with stars. This is masking, and it prevents the most common accidental leak: a command echoing its own password to the log.
But masking is a safety net, not a guarantee. It works by recognizing the exact secret text. If a secret is changed in some way before it is printed, such as being split into pieces, converted to another form, or embedded inside a longer encoded string, the mask may not recognize it. Also, a careless step can send a secret somewhere other than the log, for example to a file that is later saved as an artifact. So the rule is: never print secrets on purpose, and do not rely on masking as your only protection.
In pipelines, there is a known pitfall with how text is assembled. If a secret is blended into a longer piece of text using the wrong kind of quotation, the value can be exposed to the process list or the log in ways that masking cannot catch. Follow the guidance for using credentials inside pipeline steps, and use single quotes so that the shell, not the pipeline script, does the substitution.
Protecting the keys themselves
Because the keys unlock everything, the secrets folder deserves special care. Restrict file permissions on the controller so only the Jenkins service account can read it. Do not include it in casual backups that many people can access. And never copy it into a code repository or a chat message.
10Permissions: Who Can Do What
A safe with no rules about who can open it is not much of a safe. Jenkins lets you decide exactly who may see, use, and change credentials.
Permissions in Jenkins are handled by an authorization setting, which decides what each person may do. For credentials, the important permissions are as follows.
View
Allows a person to see that credentials exist and read their names, IDs, and descriptions. It never reveals the secret value.
Create
Allows adding new credentials to a store.
Update
Allows replacing the secret or editing the details of an existing credential.
Delete
Allows deleting a credential. Deleting one that jobs still use will make those jobs fail.
Manage domains
Allows creating and changing domains inside a store.
Use item
Allows a job or a person to use a credential in a build without being able to see or change it.
A sensible split of duties
| Role | Suggested rights | Why |
|---|---|---|
| Jenkins administrators | Full control of the main store and domains | They own the platform and its security |
| Team leads | Create, update, and delete inside their own folder’s store | They manage their team’s secrets without touching others |
| Developers | Use credentials in jobs; view names only | They can build and deploy without ever seeing values |
| Auditors or managers | View the list, with no ability to change | They can check what exists without risk |
Even people who can only “use” a credential can sometimes extract it if they can edit and run pipeline scripts, because a script can write a secret to a place where it can be read. This is why permission to edit pipelines must be handled with care, as we explore in the security chapter.
11Data Flow and the Life of a Credential
Every secret has a life story, from creation to retirement. Managing that whole story is what keeps a store healthy.
Issued
A secret is created at its source, such as a code host generating a token, ideally with narrow powers and an expiry date.
Stored
An administrator or team lead saves it in the right store, with a clear ID, a good description, and the correct scope.
Used
Jobs refer to it by ID. Jenkins lends it briefly to the builds that need it and masks it in logs.
Monitored
Someone tracks where it is used, when it expires, and whether it is still needed.
Rotated
On a schedule, or after any suspected leak, a new secret is issued and saved in place of the old one.
Retired
When no job needs it any more, it is deleted from the store and revoked at its source so it can never be used again.
Rotation: changing secrets on purpose
Rotation means replacing a secret with a fresh one regularly. Even if a secret was quietly copied by an attacker, rotation makes the stolen copy useless after a while. The credentials store makes rotation easy: edit one entry, and every job that refers to its ID uses the new value from the next build onward. This is a big advantage over secrets copied into many places.
flowchart LR A["Issue New Secret at Source"] --> B["Save in Credentials Store under Same ID"] B --> C["Jobs Use New Value Automatically"] C --> D["Revoke Old Secret at Source"] D --> E["Confirm Builds Still Pass"]
Write the expiry date of every credential into its description. A simple monthly look at the list then catches soon-to-expire secrets before they break your builds.
12Security Best Practices for the Store
The credentials store is only as safe as the habits around it. These rules make it much stronger.
Rules for the secrets themselves
- Least privilege. Give each secret only the powers it needs. A token that only reads code should not also be able to delete repositories.
- Prefer tokens and keys to personal passwords. They can be narrow, expire, and be revoked without affecting a human account.
- Use machine identities. Do not use a real person’s login. When that person leaves, automation must not break, and the account must not stay powerful.
- One secret per purpose. Do not reuse one token for ten different tasks. If it leaks, everything is exposed together.
- Rotate regularly, and immediately after any suspicion of leak.
Rules for using them in builds
- Bind narrowly. Wrap a credential around only the steps that need it.
- Never print secrets. Do not echo them, and do not write them into files that get archived.
- Use the right quoting in pipelines, so that secrets are not exposed in ways masking cannot catch.
- Do not use secrets in untrusted builds. Pull requests from strangers should build without access to any secret.
- Keep secrets out of parameters. Ordinary text parameters are shown in history. Use a hidden password parameter or a stored credential.
Rules for the platform
- Run builds on agents, not on the controller, so build code cannot reach the encryption keys.
- Restrict who can edit pipelines and jobs. Whoever can change a script that uses a credential can often extract it.
- Protect the secrets folder and back it up securely, together with the credentials settings.
- Keep Jenkins and plugins updated. Security fixes for the credentials feature arrive through updates.
- Use HTTPS so secrets typed into the web page are not readable in transit.
- Audit changes. Record who created, changed, or deleted a credential and when.
Treat “who can edit a pipeline” as equal to “who can read the secrets that pipeline uses”. If that sounds too risky, move sensitive deployments to a separate, tightly controlled job or folder.
13Backup, Recovery, and High Availability
What happens if the controller disk dies, or you move Jenkins to a new machine? The secrets must survive, without becoming easier to steal.
Because a credential is stored as encrypted data and can only be read with the matching keys, a good backup must include both: the credentials settings and the secrets folder that holds the keys. If you back up only the encrypted settings, then after a disaster you will have scrambled data with no key, and every stored secret is lost. If you carelessly back up the keys together with the data in a place many people can read, you have handed out the whole safe.
Back up both pieces, stored securely
Copy the credentials settings and the secrets folder together, and keep the backup in a place with strict access and its own encryption. Treat the backup as sensitive as the store itself.
Practice a restore
A backup you have never restored is only a hope. Try recovering onto a test machine, and confirm that a job can still use a credential.
Know your fallback
Since secret values cannot be read back from Jenkins, keep a way to recreate each secret at its source, such as issuing a new token, if the backup ever fails.
Moving to a new server
When moving Jenkins, move the settings and keys together. If the keys change, the old encrypted values cannot be read, and each credential must be entered again.
Multiple controllers
Large companies often run many Jenkins controllers. Keeping the same secrets consistent across all of them by hand is error-prone. An outside secrets service or a configuration-as-code approach helps.
The credentials store is a single point of dependency. If the controller is down, no job can fetch its secrets. Plan the availability of your controller with that in mind.
14Monitoring, Logging, and Troubleshooting
When something goes wrong with a credential, a few clues quickly point to the cause.
Common problems and their meanings
| Symptom | Likely cause | What to check |
|---|---|---|
| Build fails with “credentials not found” | Wrong ID, wrong store, or the credential is not visible from the job’s folder | The ID spelling, and whether the credential lives in a store the job can reach |
| Authentication failed at the target | Secret expired, revoked, or changed | The expiry date, and test the secret at its source |
| Permission denied at the target | The account behind the secret lacks rights | The powers granted to the token or key |
| Credential does not appear in the drop-down | Wrong domain, wrong scope, or missing permission | The domain match, the scope, and your rights |
| Secret appears in the log | The value was transformed or printed before masking could catch it | Stop printing it, avoid transforming it, rotate the secret |
| Everything failed after a restore or move | Encryption keys were not restored with the data | Whether the secrets folder came along; re-enter credentials if not |
| SSH login fails | Wrong key, missing passphrase, or unknown server key | The key pair match, the passphrase, and the server’s trusted key setting |
Watching for trouble
Expiry tracking
Keep a list of when each secret expires and a reminder well ahead of time.
Usage tracking
Jenkins can show where a credential is used. Unused ones should be removed.
Audit trail
Record who creates, edits, or deletes credentials, and review it periodically.
Log scanning
Some teams scan build logs and artifacts for patterns that look like secrets, to catch leaks early.
The console output of a build shows whether a credential was found and bound, and any errors from the target. The Jenkins system log records events from the credentials plugins. The target system, such as the code host or the cloud provider, usually keeps its own log showing which secret was used and whether the attempt succeeded.
15Advantages, Disadvantages, and Trade-offs
The basic credentials store is simple and effective, but it has limits worth knowing.
Advantages
- Built in, with no extra system to install
- Secrets encrypted on disk and hidden after saving
- Jobs use credentials by name, so secrets never appear in job settings
- Masking protects logs from the most common accidental leak
- One place to update a secret, and every job follows
- Scopes, domains, folders, and permissions control who can use what
- Supports the most common secret types
Disadvantages
- Secrets live on the controller, so the controller is a high-value target
- Anyone who can edit a pipeline may be able to extract a secret
- Masking is imperfect and does not catch transformed secrets
- No built-in automatic rotation or expiry warnings
- Manual management gets hard across many controllers
- Encryption keys must be backed up and guarded carefully
Basic store versus an external secrets service
Large organizations often connect Jenkins to a dedicated secrets service, such as a vault product or a cloud provider’s secrets manager. In that model, the real secrets live outside Jenkins, Jenkins asks for them only when needed, and they can be short-lived and rotated automatically. The basic store is simpler and perfectly good for small and medium setups. External services add strength and automation, at the cost of more moving parts.
| Question | Basic credentials store | External secrets service |
|---|---|---|
| Setup effort | Very low; already inside Jenkins | Higher; another system to run and connect |
| Where secrets live | On the Jenkins controller, encrypted | In the outside service; Jenkins fetches them on demand |
| Rotation | Manual | Often automatic, with short-lived secrets |
| Audit detail | Basic | Rich, with per-access records |
| Best for | Small to medium teams, quick start | Large or regulated organizations |
16Design Patterns and Anti-Patterns
A pattern is a proven habit. An anti-pattern is a tempting shortcut that usually hurts later.
Patterns that work
Secrets by name, never by value
Every job refers to credential IDs only. No secret value ever appears in a job setting, script, or repository.
Folder-level isolation
Each team keeps its secrets in its own folder store, so one team’s leak or mistake cannot touch another’s.
System scope for infrastructure
Mail server logins and agent connections use system scope, so no pipeline can borrow them.
Narrow, machine-owned tokens
Use tokens belonging to an automation account, limited to what is needed, with an expiry date.
Short binding blocks
Lend a credential only around the exact steps that use it, and only in the stage that needs it.
Regular rotation and cleanup
Rotate on a schedule, and delete credentials that no job uses any more.
Separate deploy jobs
Keep production credentials in a small, tightly controlled job, with approval steps and limited editors.
Anti-patterns to avoid
The pattern
Typing passwords directly into build steps, job settings, or the Jenkinsfile.
Why it hurts
Anyone who can read the job, the log, or the repository can read the secret, and it lives on in backups and history.
The better way
Store the secret in the credentials store and refer to it by ID.
The pattern
Using one powerful, all-purpose credential for everything, often a personal admin account.
Why it hurts
One leak exposes everything. When that person leaves, everything breaks, or worse, the account stays active.
The better way
Use separate, narrow, machine-owned credentials for each purpose.
The pattern
Binding a credential around the whole pipeline, when only one step needs it.
Why it hurts
Every stage, and every tool it runs, gets the secret, increasing the chance of accidental exposure.
The better way
Wrap the credential around only the smallest block that needs it.
The pattern
Relying on masking as the main defense, and printing secrets while debugging.
Why it hurts
Masking misses altered forms of a secret, and debug output is often archived or shared.
The better way
Never print secrets on purpose. If one leaks, rotate it immediately.
The pattern
Letting builds from untrusted pull requests use credentials.
Why it hurts
A stranger can propose a change to the pipeline that sends the secrets away.
The better way
Build untrusted changes on isolated agents with no credentials, and only run sensitive stages on reviewed, merged code.
The pattern
Leaving unused and forgotten credentials in the store forever.
Why it hurts
Each one is a live key that nobody watches. Old ones are the easiest for an attacker to find and misuse.
The better way
Review the list regularly, delete what is unused, and revoke it at its source.
17Best Practices and Common Mistakes
These habits separate a safe Jenkins from a leaky one.
Best practices
- Put every secret in the credentials store, and refer to it only by ID.
- Choose the right type: secret text for tokens, username with password for logins, SSH key for servers, secret file for whole files, certificate for certificate login.
- Use clear IDs and descriptions that say what the credential is for, who owns it, and when it expires.
- Use system scope for Jenkins’ own infrastructure secrets, and global scope only for what builds truly need.
- Keep team secrets in folder stores so teams cannot use each other’s credentials.
- Use narrow, machine-owned tokens instead of personal passwords, with expiry dates.
- Bind credentials only around the steps that need them.
- Never print secrets, and do not rely on masking alone.
- Do not expose credentials to untrusted pull requests.
- Limit who can edit pipelines and manage credentials, using role-based permissions.
- Rotate on a schedule, and immediately after any suspected leak.
- Back up the credentials settings and the secrets folder together, in a tightly protected place, and practice a restore.
- Run builds on agents, not on the controller.
- Audit and clean up regularly, deleting unused credentials and revoking them at the source.
- Keep Jenkins and its plugins updated to receive security fixes.
Common mistakes
Random or vague IDs
IDs such as cred1 make it easy to pick the wrong one. Choose meaningful names from the start.
Wrong type for the job
Putting a token into a username-and-password entry, or the reverse, causes confusing login failures.
Backing up only half
Saving the settings without the keys means encrypted secrets that can never be opened again.
Deleting a credential in use
Jobs that still refer to it begin failing. Check usage before deleting.
Expired tokens
Builds suddenly fail with an authentication error. Track expiry dates and rotate ahead of time.
Everything in global scope
Making every secret available to every job increases the damage from any single mistake.
Secrets in text parameters
Ordinary parameters show their values in history and logs. Use stored credentials instead.
Sharing a personal account
Using one person’s login for automation breaks when they leave and hides who did what.
Run a “leak drill” once a year. Pick a credential, pretend it was leaked, and time how long it takes to rotate it everywhere. If the answer is minutes, your setup is healthy. If it is days, simplify how secrets are used.
18Real-World Usage
The credentials store sits behind almost every real Jenkins job. Here are common ways teams use it.
Fetching private code
A job needs to download code from a private repository. The team stores a read-only token or SSH key as a credential and selects it in the source code section. Jenkins uses it for every clone and fetch, and nobody ever sees the value.
Publishing packages
A pipeline uploads a finished package to an artifact repository. A username-and-token credential is bound to variables only around the upload step, so the rest of the pipeline never sees it.
Deploying to servers
A deploy stage connects to servers over SSH with a private key stored as a credential in a tightly controlled folder. Only a small group can edit that job, and an approval step guards the deployment.
Calling cloud services
A pipeline uses a cloud access key as a secret text credential to create test environments, then destroys them. The key is narrow, expires soon, and is rotated every month.
Signing releases
A release job uses a certificate credential to digitally sign the program, so users can verify it is genuine. The certificate lives in a system-protected folder with very few people allowed near it.
Team isolation in a large company
Each product team owns a folder with its own credential store. Team members can use their secrets but cannot see other teams’ secrets. Administrators manage only the shared infrastructure credentials in system scope.
Large engineering organizations
Companies running Jenkins at large scale, with thousands of pipelines and many controllers, commonly connect Jenkins to an external secrets service so that credentials are short-lived and rotated automatically, and keep the basic store for a few low-risk cases. Internet-scale companies such as Netflix have publicly described using Jenkins as part of their delivery flow alongside other tools.
A typical growth story
A small team begins by pasting a repository password into a job. After a colleague accidentally posts a log in a chat, they move that password into the credentials store and use it by name. Next they replace the personal password with a limited token owned by an automation account, then give every credential a clear ID and description. As the company grows, each team gets its own folder store, infrastructure secrets move to system scope, and rotation becomes a monthly habit. Finally, the biggest deployments start fetching short-lived secrets from an outside secrets service. At each step the change was small, and the team never had to start over.
19Frequently Asked Questions
JENKINS_HOME. The values are stored encrypted, and the encryption keys are kept in a protected secrets folder.20Summary and Key Takeaways
You started in a hotel with a locked key cabinet and finished with a full picture of how Jenkins keeps its secrets and lends them safely.
Key Takeaways
- The credentials store is Jenkins’ encrypted safe. Secrets live in one place, jobs refer to them by ID, and Jenkins lends them briefly and hides them in logs.
- Pick the right type. Use secret text for tokens, username with password for logins, SSH key for servers, secret file for whole files, and certificate for certificate login.
- Scopes, domains, and folders draw boundaries. Use system scope for Jenkins’ own infrastructure secrets, and folder stores to keep teams apart.
- Bind narrowly and never print. Wrap a credential around only the steps that need it, and remember that masking is a safety net, not a guarantee.
- Whoever edits a pipeline can often reach its secrets. Limit who may edit sensitive jobs, and never run untrusted code with credentials.
- Manage the whole life of a secret. Issue narrow tokens with expiry dates, describe them clearly, rotate regularly, and delete and revoke what is no longer used.
- Protect the keys as much as the data. Back up the credentials settings and the secrets folder together, store them securely, practice a restore, and consider an external secrets service as you grow.