gpt4 book ai didi

git - 是否可以从 Jenkins 文件中的 Vault 获取凭据?

转载 作者:太空狗 更新时间:2023-10-29 14:43:10 26 4
gpt4 key购买 nike

我想将 ssh key 存储到 HashiCorp Vault 中的 git,然后在我的 Jenkins 文件中我想获取我的 key 并使用它来 check out 并提交到存储库,是否可能或者我应该采用传统方式,在 Jenkins 中定义凭据然后使用它。这个问题的目的是因为我想将所有 secret 信息保存在 Vault 中

最佳答案

我相信您正在寻找 Hashicorp Vault Plugin - 这可以让您访问 Jenkinsfile 中的 secret as shown here :

node {
// define the secrets and the env variables
def secrets = [
[$class: 'VaultSecret', path: 'secret/testing', secretValues: [
[$class: 'VaultSecretValue', envVar: 'testing', vaultKey: 'value_one'],
[$class: 'VaultSecretValue', envVar: 'testing_again', vaultKey: 'value_two']]],
[$class: 'VaultSecret', path: 'secret/another_test', secretValues: [
[$class: 'VaultSecretValue', envVar: 'another_test', vaultKey: 'value']]]
]

// optional configuration, if you do not provide this the next higher configuration
// (e.g. folder or global) will be used
def configuration = [$class: 'VaultConfiguration',
vaultUrl: 'http://my-very-other-vault-url.com',
vaultCredentialId: 'my-vault-cred-id']

// inside this block your credentials will be available as env variables
wrap([$class: 'VaultBuildWrapper', configuration: configuration, vaultSecrets: secrets]) {
sh 'echo $testing'
sh 'echo $testing_again'
sh 'echo $another_test'
}
}

关于git - 是否可以从 Jenkins 文件中的 Vault 获取凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45568890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com