hashicorp Vault与Jenkins管道的集成

问题描述 投票:0回答:1

我已经在k8s集群中安装了hashicorp保险库,我已经从UI存储了kv机密,正在寻找文档或链接来从jenkins管道中检索这些机密。

jenkins-pipeline hashicorp-vault
1个回答
1
投票

有一个插件可以完全做到这一点:https://github.com/jenkinsci/hashicorp-vault-plugin#usage-via-jenkinsfile

node {
    // define the secrets and the env variables
    // engine version can be defined on secret, job, folder or global.
    // the default is engine version 2 unless otherwise specified globally.
    def secrets = [
        [path: 'secret/testing', engineVersion: 1, secretValues: [
            [envVar: 'testing', vaultKey: 'value_one'],
            [envVar: 'testing_again', vaultKey: 'value_two']]],
        [path: 'secret/another_test', engineVersion: 2, secretValues: [
            [vaultKey: 'another_test']]]
    ]

    // optional configuration, if you do not provide this the next higher configuration
    // (e.g. folder or global) will be used
    def configuration = [vaultUrl: 'http://my-very-other-vault-url.com',
                         vaultCredentialId: 'my-vault-cred-id',
                         engineVersion: 1]
    // inside this block your credentials will be available as env variables
    withVault([configuration: configuration, vaultSecrets: secrets]) {
        sh 'echo $testing'
        sh 'echo $testing_again'
        sh 'echo $another_test'
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.