Variable in variable (OD-682)
yuguanpei opened 4 years ago

I have configured two Job Secrets

  - master_key: 1111
  - main_key: 2222

How can I get the secret by branch name 🙂

@secrets:@branch@_key@ => @secrets:master_key@ => 1111
  • Robin Shen commented 4 years ago

    Variable in variable is not supported. However you can achieve this via script. To do it, please switch to menu Administration / Groovy Scripts to define a script with name say get-branch-aware-key with below content:

    if (build.branch != null)
        return build.getJobSecretAuthorizationContext().getSecretValue(build.branch + "_key")
    else
        return "default_key" 
    

    Then you can use @script:get-branch-aware-key@ to get value of desired secret

  • Robin Shen changed state to 'Closed' 4 years ago
    Previous Value Current Value
    Open
    Closed
  • Robin Shen referenced from other issue 2 years ago
issue 1/1
Type
Question
Priority
Major
Assignee
Issue Votes (0)
Watchers (4)
Reference
OD-682
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover