Can't access secret from pull request events

Hello guys, my drone was working without problem until yesterday, where just stopped retriving secret without any change from my yml file. I’m missing something?

I’m using drone version 0.8.5

drone secret add -event pull_request -event push -repository autorei/slackbot-go -name sonar_login -value secret

pipeline:
  test-01:
    image: test/drone-builder
    when: 
      event: pull_request
    commands:
      - echo "$${sonar_login}"
      - echo "$sonar_login"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    secrets: [sonar_login]
$ drone secret ls test/test
sonar_login
Events: pull_request, push
Images: <any>

Owner: autorei
Repo: test
Type: git
Config: .drone.yml
Visibility: private
Private: true
Trusted: true
Gated: false
Remote: https://github.com/test/test
$ drone build info test/test 36
Number: 36
Status: success
Event: pull_request
Commit: aec746af425d2a388a5d7ef7a40c231f0cc3f900
Branch: master
Ref: refs/pull/21/merge
Message: fix
Author: dns
+ echo "${sonar_login}"

+ echo "$sonar_login"

Named secrets are passed to the container as uppercase variables [1] so you need to make the following adjustments:

pipeline:
  test-01:
    image: test/drone-builder
    when: 
      event: pull_request
    commands:
-     - echo "$${sonar_login}"
-     - echo "$sonar_login"
+     - echo "$${SONAR_LOGIN}"
+     - echo "$SONAR_LOGIN"

[1] note that this behavior is documented here http://docs.drone.io/manage-secrets/

1 Like

Perfect! Thanks! (: :sunny: