[solved] Local environment not available in SSH Pipeline

Hi,
I’m using the SSH Pipeline to connect to a server and then start some application which uses python libraries located at

/home/[username]/.local/lib/python3.7/site-packages

Unfortunately, the python modules can’t be found there. I tried exporting PYTHONPATH and sourcing .bashrc and .profile in the users home directory as a build step but none of the attempts lead to success. Are users environments somehow disable as a precautionary measure?

The terminal is non-interactive, which means it does not load the bashrc file or profile by default. Also, each pipeline executes in a temporary workspace, with a temporary HOME directory to prevent overwriting important files on the host (ssh keys, netrc files, etc) and to prevent race conditions that could result from parallel steps or parallel pipelines trying to mutate the same files or folders at the same time.

You can always change the HOME directory or PATH as needed in your commands section:

steps:
- name: build
  commands:
  - export PATH=$PATH:...
  - export HOME=...
  - ...

I’m using the SSH Pipeline to connect to a server and then start some application which uses python libraries located at

If you just want to ssh into a machine and run a few commands, you may consider using docker pipelines instead, with an ssh plugin step (see appleboy/drone-ssh).

1 Like