GithubHelp home page GithubHelp logo

isabella232 / hashicorp-vault-jenkins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from disqus/hashicorp-vault-jenkins

0.0 0.0 0.0 129 KB

Jenkins pipeline step to retrieve secrets from Hashicorp's Vault server

License: MIT License

Groovy 100.00%

hashicorp-vault-jenkins's Introduction

hashicorp-vault-jenkins

Jenkins pipeline step to retrieve secrets from Hashicorp's Vault server

Install

You'll need workflow-cps-global-lib plugin.

The step itself is added to Jenkins in Manage Jenkins » Configure System » Global Pipeline Libraries

Alt text

Usage

The step must be run in a curl enabled linux node since it uses a sh step to curl Vault API. We write a secret to Vault and then query it using the step inside a Jenkins pipeline

On the Vault server:

vault write secret/test key=my-key cert=my-cert

Jenkins DSL script:

#!groovy

@Library('vault-secrets') _

def username = ''
def password = ''
def secret = ''

timeout(time:5, unit:'MINUTES') {

  def userInput = input(
      id: 'userInput', message: 'User/Password/Secret', parameters: [
      [$class: 'TextParameterDefinition', defaultValue: '', description: 'Username input', name: 'username'],
      [$class: 'PasswordParameterDefinition', defaultValue: '', description: 'Password input', name: 'password'],
      [$class: 'TextParameterDefinition', defaultValue: '', description: 'Secret to retrieve', name: 'secret']
  ])

  username=userInput['username'].toString()
  password=userInput['password'].toString()
  secret=userInput['secret'].toString()
}

node("master"){

    def data = vaultSecret("master", "http://vault.default.svc.cluster.local:8200", username, password, secret)
    echo "CERT: " + data.cert.toString() + " KEY: " + data.key.toString()
}

hashicorp-vault-jenkins's People

Contributors

amarruedo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.