Skip to content
CMO & CTO
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

  • Digital Experience
    • Experience Strategy
    • Experience-Driven Commerce
    • Multi-Channel Experience
    • Personalization & Targeting
    • SEO & Performance
    • User Journey & Behavior
  • Marketing Technologies
    • Analytics & Measurement
    • Content Management Systems
    • Customer Data Platforms
    • Digital Asset Management
    • Marketing Automation
    • MarTech Stack & Strategy
    • Technology Buying & ROI
  • Software Engineering
    • Software Engineering
    • Software Architecture
    • General Software
    • Development Practices
    • Productivity & Workflow
    • Code
    • Engineering Management
    • Business of Software
    • Code
    • Digital Transformation
    • Systems Thinking
    • Technical Implementation
  • About
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

Secrets and Credentials: Guardrails in Jenkins

Posted on May 14, 2013 By Luis Fernandez
\nJenkins is awesome until it leaks a password to your console and emails it to the whole team. \nLet�s set guardrails for secrets before a stray echo prints your prod keys to the world.\n\n\n\n

Secrets and Credentials in Jenkins without surprises

\n\n\n\nEveryone is ramping up CI, and Jenkins is the switchboard for builds, tests, and deployments in plenty of shops. Along with that comes a quiet risk. We paste API tokens, SSH keys, and database passwords into jobs because we are in a hurry, and then those secrets sit in config files, workspaces, and emails. The places secrets escape are boring but painful. Console output that logs a curl command. A build parameter that shows up in the job URL. A repo URL with user and password embedded in it. A backup of $JENKINS_HOME that lands in a shared folder. Once a secret appears in a log or a config.xml, it tends to live forever. Guardrails are not fancy tech, they are habits and a couple of plugins that make the safe path the easy path.\n\n\n\nStart with the Credentials plugin. Keep secrets in the Jenkins credential store, not in freestyle job fields, not in shell scripts, and not in SCM. Use Username with password or SSH private key entries for Git and Subversion, and feed them to the Git and SSH plugins instead of hardcoding a URL with credentials. For Maven and Gradle servers, load secrets through Config File Provider and a managed settings file, then refer to servers by id. For console output, add Mask Passwords and register patterns that must never appear in logs, then teach your team to avoid printing any env vars with names that smell like secrets. Secrets should flow into builds as environment variables or files under a temporary directory owned by the build user, but they should never go into artifacts, caches, or test reports. If a test really needs a token, give it a short lived token and scrub it on test teardown, then verify it is not archived.\n\n\n\nThe Jenkins master holds the keys to the kingdom, literally. The credential store is encrypted using a master key in $JENKINS_HOME/secrets, which means a copy of the filesystem can decrypt everything. Lock down file permissions, restrict shell access on that machine, and keep backups encrypted. Do not let anonymous users read anything, and use Matrix based security so only a tiny group can configure jobs or view credentials. Separate duties with Folders and folder scoped credentials so a mobile app team cannot touch the payments pipeline. Be picky with nodes. Connect build nodes with distinct SSH keys per node and per user instead of one shared root key, and never leave private keys on the node filesystem for convenience. If you are spinning up ephemeral agents with the Swarm client or on a cloud, make sure the node can pull credentials only at build time and leaves nothing behind when it goes down. Secrets should never be baked into VM images or AMIs, and they should not sit under /etc either.\n\n\n\nThere are a few classic traps. Parameterized builds that accept a password will leak it through URLs, the queue page, and sometimes through email notifications if you are not careful. Use credential pickers instead of free text params. Post build publishers love to talk, so tune your Mailer or SMTP notifications to avoid printing command lines. Git checkouts with a https url with user and password will end up in the console log and in .git config unless you switch to the plugin managed credential. Shell steps like set -x will spill everything, so keep tracing off on sensitive stages. For API calls, prefer netrc or a header injected by a script that reads from the credential store, and make sure that script never prints the value on failure. When in doubt, run a build and scan its console output and artifacts with a simple grep for your secret patterns. If you find one leak, treat it as a lesson and rotate that secret right away. Better to rotate on a quiet afternoon than during an outage. \n\n\n\nSmall process tweaks go a long way. Review every new job with a short secrets checklist. Is every token in the credential store. Is masking on. Are logs quiet. Are artifacts clean. Rotate tokens used by Jenkins on a schedule and give them the least scope possible. For Maven, bind server credentials only to the publishers that need them. For mobile or web builds, place signing keys in the credential store or a protected keystore on the master, load them in memory at build time, and avoid storing them on shared workspaces. Keep a simple runbook near Jenkins that lists where secrets live, who owns rotation, and how to recover a job with a new token. Add the Audit Trail plugin so changes to jobs and credentials leave a trace you can read when something goes weird. \n\n\n\nWe are all excited about Docker popping up and Vagrant getting nicer, but the basics still rule. Jenkins credentials should come from one place, pass through the smallest surface area possible, and leave no trace. The master must be treated like production. Nodes should be cattle, not pets. People should not paste secrets into job forms, even when they are tired and chasing a build breaker. The console should never print a token, and if it does, the token should be dead within minutes. These are not big tools or big budgets. They are simple guardrails that keep your CI from becoming your biggest leak.\n\n\n\nTreat Jenkins like a vault with a build button and your secrets will stay your secrets. \n
Development Practices Software Engineering

Post navigation

Previous post
Next post
  • Digital Experience (94)
    • Experience Strategy (19)
    • Experience-Driven Commerce (5)
    • Multi-Channel Experience (9)
    • Personalization & Targeting (21)
    • SEO & Performance (10)
  • Marketing Technologies (92)
    • Analytics & Measurement (14)
    • Content Management Systems (45)
    • Customer Data Platforms (4)
    • Digital Asset Management (8)
    • Marketing Automation (6)
    • MarTech Stack & Strategy (10)
    • Technology Buying & ROI (3)
  • Software Engineering (310)
    • Business of Software (20)
    • Code (30)
    • Development Practices (52)
    • Digital Transformation (21)
    • Engineering Management (25)
    • General Software (82)
    • Productivity & Workflow (30)
    • Software Architecture (85)
    • Technical Implementation (23)
  • 2025 (12)
  • 2024 (8)
  • 2023 (18)
  • 2022 (13)
  • 2021 (3)
  • 2020 (8)
  • 2019 (8)
  • 2018 (23)
  • 2017 (17)
  • 2016 (40)
  • 2015 (37)
  • 2014 (25)
  • 2013 (28)
  • 2012 (24)
  • 2011 (30)
  • 2010 (42)
  • 2009 (25)
  • 2008 (13)
  • 2007 (33)
  • 2006 (26)

Ab Testing Adobe Adobe Analytics Adobe Target AEM agile-methodologies Analytics architecture-patterns CDP CMS coding-practices content-marketing Content Supply Chain Conversion Optimization Core Web Vitals customer-education Customer Data Platform Customer Experience Customer Journey DAM Data Layer Data Unification documentation DXP Individualization java Martech metrics mobile-development Mobile First Multichannel Omnichannel Personalization product-strategy project-management Responsive Design Search Engine Optimization Segmentation seo spring Targeting Tracking user-experience User Journey web-development

©2025 CMO & CTO | WordPress Theme by SuperbThemes