Secret not working/empty

Hi,

I’m trying to use a secret within my drone.yml. I set it up on the web interface and enabled it for push, tag, deploy and pull request. But it does not seem to be assigned or injected:

pipeline:
  test:
     image: alpine
     environment:
       - FOO=bar
       - MY_SECRET=${MY_SECRET}
     commands:
       - echo $FOO
       - echo $MY_SECRET
       - echo "${MY_SECRET}"

Output:

+ echo $FOO
bar
+ echo $MY_SECRET

+ echo ""

And this is the log output:

droneagent      | pipeline: received next execution: 116
gogs            | [Macaron] 2017-06-07 11:08:57: Started GET /test/docker-go-test.git/info/refs?service=git-upload-pack for 172.28.0.1
gogs            | [Macaron] 2017-06-07 11:08:57: Completed GET /test/docker-go-test.git/info/refs?service=git-upload-pack 401 Unauthorized in     4.244154ms
gogs            | [Macaron] 2017-06-07 11:08:57: Started GET /test/docker-go-test.git/info/refs?service=git-upload-pack for 172.28.0.1
gogs            | [Macaron] 2017-06-07 11:08:57: Completed GET /test/docker-go-test.git/info/refs?service=git-upload-pack 200 OK in 14.44662ms
gogs            | [Macaron] 2017-06-07 11:08:57: Started POST /test/docker-go-test.git/git-upload-pack for 172.28.0.1
gogs            | [Macaron] 2017-06-07 11:08:57: Completed POST /test/docker-go-test.git/git-upload-pack 200 OK in 41.233605ms
droneagent      | pipeline: finish uploading logs: application/json+logs: step 116: clone
droneagent      | pipeline: finish uploading logs: 116: step clone
droneagent      | pipeline: finish uploading logs: application/json+logs: step 116: test
droneagent      | pipeline: finish uploading logs: 116: step test
droneagent      | pipeline: execution complete: 116
droneagent      | pipeline: cancel channel closed: 116
droneagent      | pipeline: request next execution
droneagent      | pipeline: cancel ping loop: 116
droneagent      | pipeline: received next execution: 116
gogs            | [Macaron] 2017-06-07 11:08:57: Started GET /test/docker-go-test.git/info/refs?service=git-upload-pack for 172.28.0.1
gogs            | [Macaron] 2017-06-07 11:08:57: Completed GET /test/docker-go-test.git/info/refs?service=git-upload-pack 401 Unauthorized in 4.244154ms
gogs            | [Macaron] 2017-06-07 11:08:57: Started GET /test/docker-go-test.git/info/refs?service=git-upload-pack for 172.28.0.1
gogs            | [Macaron] 2017-06-07 11:08:57: Completed GET /test/docker-go-test.git/info/refs?service=git-upload-pack 200 OK in 14.44662ms
gogs            | [Macaron] 2017-06-07 11:08:57: Started POST /test/docker-go-test.git/git-upload-pack for 172.28.0.1
gogs            | [Macaron] 2017-06-07 11:08:57: Completed POST /test/docker-go-test.git/git-upload-pack 200 OK in 41.233605ms
droneagent      | pipeline: finish uploading logs: application/json+logs: step 116: clone
droneagent      | pipeline: finish uploading logs: 116: step clone
droneagent      | pipeline: finish uploading logs: application/json+logs: step 116: test
droneagent      | pipeline: finish uploading logs: 116: step test
droneagent      | pipeline: execution complete: 116
droneagent      | pipeline: cancel channel closed: 116
droneagent      | pipeline: request next execution
droneagent      | pipeline: cancel ping loop: 116

Screenshot of the secret: https://mb.embe-it.de/media/screenshots/secret.png

HI @DeKugelschieber,

Looks like you’re probably on .6 or .7 and secrets have changed from .5. if that’s the case http://docs.drone.io/manage-secrets/ has the current way to use secrets. I believe in you’re case you’d have to add the secrets: [ MY_SECRET ] to the .drone.yml and I don’t think you need the environment MY_SECRET value, but don’t quote me on that :slight_smile:

1 Like

Yes that works:

pipeline:
  test:
    image: alpine
    secrets: [my_secret]
    commands:
      - echo $MY_SECRET

Thank you!
Btw. there is way to many documentation in too many places. I looked at readme.drone.io.