DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Why Round-Robin Won't Save You: Load Balancing Challenges in Data Streaming Services With Heterogeneous Traffic
  • Good Data, Bad Metric: A Mutation Testing Pattern for Analytics Engineering
  • A System Cannot Protect What It Does Not Understand
  • Using LLMs to Automate Data Cleaning and Transformation Pipelines

Trending

  • Pragmatica Aether: Let Java Be Java
  • When One MVP Is Really Four Systems: A Better Way to Plan Multi-Role Apps
  • 5 Common Security Pitfalls in Serverless Architectures
  • Why DDoS Protection Is an Architectural Decision for Developers
  1. DZone
  2. Data Engineering
  3. Data
  4. Jenkins Configuration as Code: Sensitive Data

Jenkins Configuration as Code: Sensitive Data

Learn how to manage Jenkins configuration using declarative YAML files and SCM with the configuration as code concept.

By 
Nicolas De Loof user avatar
Nicolas De Loof
·
Sep. 04, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
8.6K Views

Join the DZone community and get the full member experience.

Join For Free

This blog post is the second of a six-part Configuration as Code series.

Using Configuration as Code, one can manage the configuration of a Jenkins master with simple, declarative YAML files, and manage them as code in SCM. But this doesn't mean you have to commit passwords and other sensitive information in Git.

What About Sensitive Data?

Managing sensitive data was one of the first requested features for JCasC. We chose to support string substitution so one can write and share YAML configuration samples, without any risk of exposing sensitive information.

credentials:
system:

    # global credentials
    - credentials:
        - certificate:
            scope: SYSTEM
            id:       ssh_private_key
            password: ${SSH_KEY_PASSWORD}
            keyStoreSource:
              fileOnMaster:
                keyStoreFile: /docker/secret/id_rsa

This YAML document can safely be committed to Source Code Management (SCM), or even shared publicly, as it only describes how to set the Secure Shell (SSH) key with a secret passphrase. The passphrase is only available at runtime.

Not Just Sensitive Data

This mechanism has been designed for sensitive data, but we quickly noticed it would also make it easier to customize configurations without the need to edit a YAML document, just like bash environment variables are widely used. So to extend this idea, we also support default values for such parameters, using bash-style syntax: ${PARAMETER:-defaultvalue}.

In doing so, one can design a general purpose set of YAML files to set up Jenkins in a ready-for-service state, relying on reasonable default values. It also gives us an opportunity to customize some values without forking the YAML configuration and then having to merge upstream changes to stay updated.

tool:
git:

  installations:
    - name: git
      home: ${GIT_PATH:-usr/local/bin/git}

Sources

String replacement supports multiple sources and can be extended with a simple API to support more in the near future.

We support environment variables, which perfectly match the default-value override scenario, but are a very bad idea for sensitive data - those would leak in the Jenkins UI and logs.

We also support Hashicorp Vault secret storage, relying on environment variables to configure access to the Vault API with an adequate token.

We also support Docker and Kubernetes secrets. If you've never used these, just know there's no magic here. Both Docker and Kubernetes can manage secrets at the cluster level and inject them into a container at runtime. They use a simple directory with one file per secret, with the file content being the secret's value. This pattern can be implemented by many other tools if you want to integrate your own system without writing a custom Jenkins plugin for it.

Finally, this API is fully extensible for other use-cases and integrations. If you want integration for your favorite tool and have some Java development skills, developing an adapter plugin would be pretty trivial.

OK, So What's Next?

You can read more about the Jenkins Configuration as Code plugin on the project's GitHub repository. To chat with the community and contributors join our gitter channel Or, come see us in person at DevOps World | Jenkins World 2018 to discuss the JCasC project and its future!

Also, don't miss next post from the Configuration as Code series, where we'll go over how to configure specific plugins and show some examples with a few of our favorites.

Jenkins (software) Data (computing)

Published at DZone with permission of Nicolas De Loof. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Why Round-Robin Won't Save You: Load Balancing Challenges in Data Streaming Services With Heterogeneous Traffic
  • Good Data, Bad Metric: A Mutation Testing Pattern for Analytics Engineering
  • A System Cannot Protect What It Does Not Understand
  • Using LLMs to Automate Data Cleaning and Transformation Pipelines

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook