Why environment and envs are not working?

Hi there!

Options ‘environment’ and ‘envs’ are not working?
What is wrong?

Config:

kind: pipeline
name: "env testing"
type: docker

platform:
  os: linux
  arch: arm64

steps:
- name: env_test
  image: appleboy/drone-ssh
  pull: if-not-exists
  environment:
    ENV_TEST: it_is_test
  settings:
    envs:
    - deploy_login
    host:
      from_secret: deploy_host
    username:
      from_secret: deploy_login
    key:
      from_secret: deploy_key
    port: 22
    script_stop: true
    script:
    - echo ENV_TEST=$${ENV_TEST}
    - echo ENV_TEST=$$ENV_TEST
    - echo ENV_TEST=$ENV_TEST
    - echo DEPLOY_LOGIN=$$DEPLOY_LOGIN
    - echo DEPLOY_LOGIN=$DEPLOY_LOGIN

Console logs:

======CMD======
2	echo ENV_TEST=${ENV_TEST}
3	echo ENV_TEST=$ENV_TEST
4	echo ENV_TEST=$ENV_TEST
5	echo DEPLOY_LOGIN=$DEPLOY_LOGIN
6	echo DEPLOY_LOGIN=$DEPLOY_LOGIN
7	======END======
8	out: ENV_TEST=
9	out: ENV_TEST=
10	out: ENV_TEST=
11	out: DEPLOY_LOGIN=
12	out: DEPLOY_LOGIN=
13	==============================================
14	✅ Successfully executed commands to all host.
15	==============================================

environment variables are injected into the appleboy/drone-ssh container, but your script is executed on a remote machine where those environment variables are not accessible.

1 Like