Unable to source the scripts when creating the buildkite image

Hi Team,

We have created a custom buildkite docker image which has a scripts directory and under which we have a bash script .
The image gets created successfully but the script is not able to get sourced correctly resulting that we need to source the script explicitly in our terraform steps

This is how we are sourcing it in pipeline steps :slight_smile:

steps:

  • key: “buildkite-docker”
    label: “Build agent image in {{matrix.queue}} and push to {{matrix.region}}”
    command: “source scripts/abc.sh && make”
    agents:
    queue: “{{matrix.queue}}”

Hey @rajat2911 :wave:

Are you aiming to use the script within the Docker container? Do you have a COPY step in your Dockerfile which ensures the file is in the image on build?

The above step doesn’t seem to be using the Docker container/image, but it may just not be clear from what’s been shared. Do you think you could email us at support@buildkite.com with some more info; a link to the build/pipeline?

Cheers!

Hi @benmc Thanks for updating on this issue
Yes in docker file i am using like this

Copy custom scripts and hooks

COPY scripts /usr/local/bin/
COPY hooks /buildkite/hooks/

Copy entrypoint scripts

COPY entrypoint /docker-entrypoint.d/

and i am sourcing in a script under hooks/environment but when i run the terraform steps , it fails because its not able to load the environment vairables that are defined in the script

Hey @rajat2911 :wave:

From what you’ve shared so far, I’m not able to see any reasons why it wouldn’t be working, but I think we’re missing some key component of how you’re configuring your environment here.

Is the environment hook exporting scripts into the container that is running terraform? Or is the environment hook referencing variables that are not being set in the container?

If possible, could you reach out via email to support@buildkite.com with some more info - a link to the build/pipeline, as well as some more details around your environment such as the hooks you are using, and what the abc.sh (assuming this isn’t the actual script name) script and make are doing in this instance?

Thanks!

Hello @Jeremy,

I’d like to clarify my question to ensure a better understanding.

We’ve created a Buildkite image that includes a directory named scripts, where we have a bash script that gets copied to /usr/local/bin. This script defines several variables and functions. We source this script in the hooks/environment file using the following line:

source /usr/local/bin/myscript.sh

Buildkite is successfully reading the variables from the script, but when we try to call a function from the script, we encounter an error: “command not found.”

Could you help us understand why the variables are working, but the functions are not being recognized?

Hi @rajat2911 ,

Have you explored making the script files executable before copying to the Docker image?

And as mentioned by Jeremy, could send us - details (build link/url) of your build/pipeline and the docker file to customise your Buildkite image - via email to support@buildkite.com. That would give us a better understanding of your setup and allow us to assist you better with issue.

Cheers.

Hello @lizette
Is it possible to have a meeting with buildkite to explain how m doing ?
The concern is the variables are available in when we source the script from environment but the function is not available which i am using in another script ?

Sent an email to support@buildkite.com from my official email ID