Bitbucket pipelines use image for build with specific parameters

Martí Bastida Comas September 18, 2024

Hi,

 

I have a public docker image that when being used on my computer I do the following:

 

docker run --rm -it espressif/idf:v4.4.7

Note the -it flag. If I run this docker command I can  access the container and do things there, Mainly idf.py clean.

I want to do this from a pipeline:

 

 

image: espressif/idf:v4.4.7
pipelines:
  default:
      - step:
          name: 'Compile all platforms'
          script:
            - ls
            - idf.py clean

The last line fails because it doesn't find idf.py. I supose that is because bitbucket is not executing the image as -it. Is there a way to do so?

bash: idf.py: command not found

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 19, 2024

Hey @Martí Bastida Comas ,

and thank you for reaching out to Community!

When I spinned a container with the image that you shared, the following logs were printed right away:

$ docker run --rm -it espressif/idf:v4.4.7 /bin/bash

Detecting the Python interpreter
Checking "python" ...
Python 3.8.10
"python" has been detected
Adding ESP-IDF tools to PATH...
Using Python interpreter in /opt/esp/python_env/idf4.4_py3.8_env/bin/python
Checking if Python packages are up to date...
Python requirements from /opt/esp/idf/requirements.txt are satisfied.
Added the following directories to PATH:
  /opt/esp/idf/components/esptool_py/esptool
  /opt/esp/idf/components/espcoredump
  /opt/esp/idf/components/partition_table
  /opt/esp/idf/components/app_update
  /opt/esp/tools/xtensa-esp-elf-gdb/11.2_20220823/xtensa-esp-elf-gdb/bin
  /opt/esp/tools/riscv32-esp-elf-gdb/11.2_20220823/riscv32-esp-elf-gdb/bin
  /opt/esp/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin
  /opt/esp/tools/xtensa-esp32s2-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32s2-elf/bin
  /opt/esp/tools/xtensa-esp32s3-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32s3-elf/bin
  /opt/esp/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/bin
  /opt/esp/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin
  /opt/esp/tools/cmake/3.23.1/bin
  /opt/esp/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin
  /opt/esp/python_env/idf4.4_py3.8_env/bin
  /opt/esp/idf/tools
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:
  idf.py build

This means that your image has a command set as the entrypoint that executes as soon as the image is started, setting up the environment and adding the ESP-IDF tools to the PATH (PATH is where executables are looked for).

What happens is that pipelines overwrites the image's entrypoint to /bin/bash, so pipelines can executed the script you have defined in the steps. This would be similar to starting the local container as follows:

docker run --rm -it --entrypoint=/bin/bash espressif/idf:v4.4.7

So the entrypoint you have configured in your image is actually skipped, and the container starts directly in a bash session.

As that entrypoint is apparently what is setting up the environment and setting the PATH to contain the IDF executable, skipping the entrypoint is causing the pipelines not being able to find that command idf.py in PATH.

My suggestion in this case would be to either:

  • Get the commands configured as the entrypoint in that public docker image, and manually add those commands as part of the first commands in your step's script
  • If you know the path to that executable idf.py inside the image, you can add that to the PATH variable : 
    export PATH=$PATH:/<path to the executable>

I hope that helps! Let us know in case you have any questions.

Thank you, @Martí Bastida Comas !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events