I would like to import logics from an external shell script as part of my CircleCI configuration and I'm looking for the "correct" (or best) way to do this.
Let's assume I have the following config.yml
for CircleCI:
version: 2.1
jobs:
build:
docker:
- image: circleci/ruby:2.5.3-node-browsers
steps:
- checkout
- run:
name: Compute some value
command: |
SOME_VALUE=$(foo.sh)
- run:
name: Reuse some value
command: |
echo "Hello" > /a/path/${SOME_VALUE}.txt
The overall idea is to wrap these steps into a CircleCI Orb and then have my build configuration reuse them from the Orb. But the foo.sh
script cannot be packaged into the Orb itself, so I need some other way to make it accessible inside the build configuration.
So how I can include the foo.sh
script (or any other script or executable) into my build process?
What I see so far (and why I don't think that's the best way to do it):
foo.sh
directly as part of an Orb.circleci/XXX
, include my script in that Docker image and call it directory. I don't really like the idea as the script has nothing to do with the Docker image it's based upon - I would just misuse Docker as transportation here.wget
the script from a public location, store it temporarily and then call it from within the running container that is executing the build script. But loading content from a public URL and then executing doesn't feel right (and either a typo or some malicious work could lead to me executing some foreign shell script with god knows what content).Any ideas or best practices that I haven't thought of yet?
So how I can include the foo.sh script (or any other script or executable) into my build process?
You package it in the orb.
Here's an example in one of circle's maintained orbs:
https://github.com/CircleCI-Public/slack-orb/blob/48638f19e8b12170027cc55f06a3a924a8f8dc2d/src/commands/notify.yml#L111
command: <<include(scripts/notify.sh)>>
references the script in https://github.com/CircleCI-Public/slack-orb/blob/48638f19e8b12170027cc55f06a3a924a8f8dc2d/src/scripts/notify.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With