#682  Variable in variable
Closed
yuguanpei opened 2 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 2 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' 2 years ago
Previous Value Current Value
Open
Closed
Robin Shen referenced from other issue 6 months ago
issue 1 of 1
Type
Question
Priority
Major
Assignee
Issue Votes (0)
Watchers (4)
Reference
onedev/server#682
Please wait...
Page is in error, reload to recover