JetBrains / teamcity-hashicorp-vault-plugin

TeamCity plugin to support HashiCorp Vault
Apache License 2.0
28 stars 18 forks source link

Unable to fetch secrets from vault #61

Open chetan-dua opened 1 year ago

chetan-dua commented 1 year ago

Server Version: TeamCity Professional 2022.10.3 (build 117072) jetbrains/teamcity-server:2022.10.3 (docker image ID: c0edf4d5ae59)

Vault plugin version: 0.1.119 Agent: jetbrains/teamcity-agent (docker image ID: 45f54a688267)

Documentation referred:

  1. https://blog.jetbrains.com/teamcity/2017/09/vault/
  2. https://plugins.jetbrains.com/plugin/10011-hashicorp-vault-support

Steps to reproduce:

  1. Create a project
  2. Goto connections -> Add Connection -> Use Vault AppRole - > (Fill necessary parameters) -> Test Connection (Shows Success)
  3. Create build configuration (name=vault_test) -> Add new parameter (do not mask) -> Name: env.SECRET , Value: %vault:devops/data/api-keys!/devops-na!/secret%
  4. build step -> command-line
#!/bin/bash
echo SECRET=${SECRET}

Expected Output SECRET="ActualSecrethere"

Actual Output: SECRET=%vault:devops/data/api-keys!/devops-na!/secret%

This is same as variable value itself.

Other options tried:

  1. Name: env.VAULT_SUPPORTED Value: %teamcity.vault.supported% , Output = true
  2. Name: env.SECRET , Value: %vault:/devops/data/api-keys!/devops-na!/secret% (see / at starting of path), Output = Same as Value string but not actual secret
  3. Name: env.URL , Value: %teamcity.vault.url% , Output: (as visible in configuration parameters section)

Build Log:

[07:50:57] :     [Step 1/1] Starting: /opt/buildagent/temp/agentTmp/custom_script4451755130190608596 
[07:50:57] :     [Step 1/1] in directory: /opt/buildagent/work/2b35ac7e0452d98f
[07:50:57] :     [Step 1/1] VAULT_SUPPORTED=true
[07:50:57] :     [Step 1/1] SECRET=%vault:devops/data/api-keys!/devops-na!/secret%
[07:50:57] :     [Step 1/1] AWS_SECRET=%vault:aws/data/creds/developer!/access_key%
[07:50:57] :     [Step 1/1] Process exited with code 0
[07:50:57] : Publishing internal artifacts

I have read other reported issues in this repo already and the options haven't helped much.

Note that using vault utility on bash works fine though.

VladRassokhin commented 1 year ago

Try %vault:devops/data/api-keys!/devops-na/secret%, note that there's only one !/