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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Share Delta Lake Tables Between Databricks and Snowflake
  • Why Vulnerability Management Fails Without Reliable Asset Data
  • Engineering Audit-Ready Data Pipelines for Regulatory Reporting
  • Moving 900+ GB of Prometheus Without a Cutover Weekend

Trending

  • Building a Practical Cloud-Native Golden Path: A Guide to Kubernetes-Based Service Delivery, Self-Service, and Developer-Friendly Defaults
  • AI-Era Cybersecurity, Part 1: Mapping Glasswing, Daybreak, Lightwell and the Tools Racing to Find and Fix Bugs
  • Kafka With Spring Boot: Introduction
  • When One Docker Swarm Replica Became Unreachable Over an Overlay Network: A Production Case With Traefik

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Sep. 04, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
8.8K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • Share Delta Lake Tables Between Databricks and Snowflake
  • Why Vulnerability Management Fails Without Reliable Asset Data
  • Engineering Audit-Ready Data Pipelines for Regulatory Reporting
  • Moving 900+ GB of Prometheus Without a Cutover Weekend

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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