Confirm: Secrets usage

- secret_name: secret-testing
  secret_var: dockerpassword
  when:
    ref: '#/refs/pull/.*#'
  • 2.Now I’m using with the following
##ref
- secret_name: secret-testing
  secret_var: dockerpassword
  when:
   ref:
      include:
        #- type: simple
        - type: regexp
          match: 'refs/pull/*'

##brach
- secret_name: secret-testing
  secret_var: dockerpassword
  when:
    branch:
      include:
        - type: simple
          match: 'br-agola'
        - type: regexp
          match: 'br-*'

With pr to agola-site: fix: WhenCondition to `dockerpassword.yml` by huapox · Pull Request #25 · agola-io/agola-site · GitHub

With pr in agola: cmd: Fix WhenCondition in cobra command. by huapox · Pull Request #190 · agola-io/agola · GitHub

It works for me…

# agola --token $TOKEN --gateway-url $AGOLA_API projectgroup variable list --projectgroup org/org01

projectgroup variables:
[
        {
                "id": "8fa32c54-4ed8-441b-80cb-512942bd89ce",
                "name": "variable02",
                "values": [
                        {
                                "secret_name": "secret-testing",
                                "secret_var": "dockerpassword",
                                "matching_secret_parent_path": "",
                                "when": {
                                        "ref": {
                                                "include": [
                                                        {
                                                                "type": "regexp",
                                                                "match": "/refs/pull/.*"
                                                        }
                                                ]
                                        }
                                }
                        }
                ],
                "parent_path": "org/org01"
        }
]

It’s works for me now, I may executed with old agolademo image. thx~

$ ./agola --token "xxx" -u $api projectgroup variable $cmd --projectgroup $group --name $varname -f ./var1.yml
2019-12-14T17:03:56.567+0800    INFO    cmd/projectvariablecreate.go:142        creating project group variable
2019-12-14T17:03:56.871+0800    INFO    cmd/projectvariablecreate.go:147        project group variable "dockerpassword-02" created, ID: "589c0663-d119-4310-a1cd-bxxxfac490"
1 Like