- master_key: 1111 - main_key: 2222
How can I get the secret by branch name 🙂
@secrets:@branch@_key@ => @secrets:master_key@ => 1111
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:
Administration / Groovy Scripts
get-branch-aware-key
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
@script:get-branch-aware-key@
Open
Closed
I have configured two Job Secrets