Custom shell to run commands

I’m running into an issue where I believe I need to use bash (if there’s a better way I’m open)

I’m running a build for python where in part I’m installing requirements, in an other step I’m running lint and several other steps to package and deploy. I’m using venv to share the packages between containers but that requires me source the venv/bin/activate in bash :confused:

ie.

  requirements:
    image: python:3.6.1
    commands:
      - python3 -m venv ./venv
      - source ./venv/bin/activate
      - pip install -r requirements.txt -I
 
  python_lint:
    image: python:3.6.1
    commands:
      - /source ./venv/bin/activate
      - pylint

  python_deploy
    image: python:3.6.1
     .......
  

Would it be worth contributing to cncd to add a “entrypoint or shell” to set the entrypoint in a way that could be custom?

This capability is avaiable in 0.9, however we do not yet have a release candidate available for testing. That is probably a few weeks away still. But here is the relevant shell capability https://github.com/drone/drone-yaml-v1/blob/master/yaml/container.go#L46

In the mean time, you best option with 0.8 is to put your build commands inside of a shell script, and then invoke the shell script with bash, like this:

  python_lint:
    image: python:3.6.1
    commands:
+     - /bin/bash script.sh
1 Like

oh perfect timing :wink: I think I found a temporary work around till 9.0 (although the script is a good fall back)

Note that for most purposes you can run …/venv/bin/<foo> without activating the virtualenv.

1 Like

yep that was the work around I used :wink:

Hi,

Is there any progress being done for that feature?
How can I make a plugin which have bash in it, and the way to use it is to use the command section in the YAML?

If I build an image with a link from sh to bash, bash will be executed in sh compatible mode, which is not what I want to do.

Just having a ‘shell’ part may do the trick in the yaml, and I don’t want to create a shell script that is a simple line of code for each possible trigger, and I don’t want to do something like:

commands:
  - >
     bash -c "
         cmd1 <<< "${DRONE_TAG}";
         cmd2 | tee >(sed '/^$' <<< "${DRONE_TAG}" > .local_file) > .log_file"

I know those lines can be written otherwise, so that sh can parse them, the point is that I want to be able to type bash in commands.

I don’t see any way to set the shell in the docs, and actually i found this file in which /bin/sh is hard coded.
Should I make an issue, or am I missing something here?

1 Like

Does the current Drone version support configuring another shell than the default in the pipeline configuration? I tried setting environment: /bin/bash on both pipeline and individual commands and it doesn’t take.

1 Like

Same. It would be very good to be able to choose which shell to run

2 Likes

I am experiencing this major pain point also. Would make steps much nicer to write if we could choose our shell. Please let us choose our shell.