Including non bash files while authoring an orb

I see it’s possible to include bash scripts while authoring an orb (Orbs Concepts - CircleCI and Orb Authoring Process - CircleCI). Using this feature results in the script source code being pasted into the run step along with a #!/bin/bash header, i.e. a script.sh containing echo "bash script" when included in a run script via `<<include(scripts/script.sh)>> would be generated as the following:

#!/bin/bash
echo "bash script"

Is it possible to run non bash scripts in a similar fashion? Including a python script, for example including a script.py containing print ("python script") using <<include(scripts/script.py)>> results in the following:

#!/bin/bash
print ("bash script")

which of course throws an error. I tried creating a proxy bash script proxy.sh that contains python script.py but it looks like this doesn’t work as the contents aren’t extracted at compile time, thus failing as script.py doesn’t exist in the project using the orb.

Any simple solutions here or is dynamic config the only solution?

Hi @swarajrao,

This is possible if you set the shell at step level as well. Here is an example from one of our orbs:

path-filtering-orb/set-parameters.yml at main · CircleCI-Public/path-filtering-orb · GitHub

steps:
  - run:
      environment:
        BASE_REVISION: << parameters.base-revision >>
        MAPPING: << parameters.mapping >>
        OUTPUT_PATH: << parameters.output-path >>
      name: Set parameters
      shell: /usr/bin/env python3
      command: <<include(scripts/create-parameters.py)>>

Could you try to adapt this to your orb, and let us know if it works for you?

Thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.