从Jenkins管道中的Hashicorp Vault检索秘密

发布于 2025-01-26 00:44:09 字数 1236 浏览 5 评论 0原文

我正在尝试重新携带Hashicorp保险库,并在Jenkins Pipeline中使用它。我设法连接到Hashicorp保险库,但是管道未能重新考虑保存在金库中的秘密。

管道输出:

Started by user admin
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/test_pipeline
[Pipeline] {
[Pipeline] withVault
Retrieving secret: my.secrets/data/dev
Access denied to Vault Secrets at 'my.secrets/data/dev'
[Pipeline] {
[Pipeline] sh
+ echo

[Pipeline] }
[Pipeline] // withVault
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

管道: 键Heslo存在于我的secrets/data/dev路径中,

node {

    def secrets = [
        [path: 'my.secrets/data/dev', engineVersion: 2, secretValues: [
            [envVar: 'value', vaultKey: 'heslo']
      ]]     
    ]

    def configuration = [vaultUrl: 'http://10.47.0.235:8200/',
                         vaultCredentialId: 'b0467c75-24e4-4307-9a35-f7da364f6285',
                         engineVersion: 2]
  
    withVault([configuration: configuration, vaultSecrets: secrets]) {
        sh 'echo $value'
    
    }
}

我的jenkins-policy.hcl文件以获取apploe方法,用于从jenkins访问保险库:

path "my.secrets/data/dev" {
    capabilities = [ "read" ]
  }

提前谢谢您

I am trying to retreive hashicorp vault secret and use it in jenkins pipeline. I managed to connect to hashicorp vault, but pipeline fails to retreive the secret saved in vault.

Pipeline output:

Started by user admin
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/test_pipeline
[Pipeline] {
[Pipeline] withVault
Retrieving secret: my.secrets/data/dev
Access denied to Vault Secrets at 'my.secrets/data/dev'
[Pipeline] {
[Pipeline] sh
+ echo

[Pipeline] }
[Pipeline] // withVault
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Pipeline:
key heslo exists in my.secrets/data/dev path

node {

    def secrets = [
        [path: 'my.secrets/data/dev', engineVersion: 2, secretValues: [
            [envVar: 'value', vaultKey: 'heslo']
      ]]     
    ]

    def configuration = [vaultUrl: 'http://10.47.0.235:8200/',
                         vaultCredentialId: 'b0467c75-24e4-4307-9a35-f7da364f6285',
                         engineVersion: 2]
  
    withVault([configuration: configuration, vaultSecrets: secrets]) {
        sh 'echo $value'
    
    }
}

my jenkins-policy.hcl file for approle method to access vault from jenkins:

path "my.secrets/data/dev" {
    capabilities = [ "read" ]
  }

Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坠似风落 2025-02-02 00:44:09

从“路径”定义中删除“数据”:

path: 'my.secrets/dev'

您必须在策略路径中使用“数据”,而在检索秘密时必须使用。

Remove the "data" from the "path" definition:

path: 'my.secrets/dev'

You must use the "data" in the policy path but not when retrieving the secret.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文