How to use nrf-docker in Bitbucket pipeline

I want to create automatic build using CI in bitbucket pipeline.

I would like to use image /nrf-docker to compile the project. I saw the article Build NCS application firmware images using Docker - Getting Started - nRF Connect SDK guides - Nordic DevZone (nordicsemi.com)

The usage of this image looks like:

docker run --name ncs --rm -v ${PWD}:/workdir/ncs/fw-nrfconnect-nrf ncs /bin/bash -c 'cd ncs/fw-nrfconnect-nrf/applications/asset_tracker; west build -p always -b nrf9160_pca20035ns'

But I would like to first run the image, and inside run the west build command. 

There is my example runner configuration.

 

pipelines:
  default:
    - step:
        name: 'Build'
        image: nordicplayground/nrfconnect-sdk:v2.5-branch
        runs-on:
          - self.hosted
          - linux
        script:
          - echo "Building start"
          - west --version


And on output i got:

+ west --version
bash: west: command not found
How to solve this. Eventually how to modify the docker image to obtain what i want.
Parents
  • Hi, 

    The problem might be that github action does not respect the entry point as noted here

    You should try to  run nrfutil toolchain-managerexplicitly (like here).

    At tech support we don't normally interact to much with automatic build systems so I can't promise anything

    Regards

    Runar

  • I found the solution.

    I need to make the file launch_tool.sh:

    #!/bin/bash
    
    # Checking whether an argument has been passed
    if [ "$#" -eq 0 ]; then
        echo "You must provide at least one command to execute."
        exit 1
    fi
    
    # Passing the command to nrfutil toolchain-manager launch
    nrfutil toolchain-manager launch -- /bin/bash -c "$*"
    

    And the step definition

        - step: &build_for_nrf52840dk_faster
            name: 'Build for nrf52840dk board'
            image: nordicplayground/nrfconnect-sdk:v2.7-branch
            runs-on:
              - linux
            script:
              - HW_VERSION="0.0.0"
              - source /workdir/zephyr/zephyr-env.sh # make visible west build
              - chmod +x launch_tool.sh              # make launch_tool.sh executable
              - ./launch_tool.sh west --version      # check west version
              - ./launch_tool.sh west build
                --pristine=always
                --board nrf52840dk/nrf52840
                --build-dir ${PWD}/build
                --
                -DBOARD_ROOT=${PWD}
                -DCONF_FILE=${PWD}/prj.conf
              - mv build/zephyr/zephyr.hex nrf52840dk_v${HW_VERSION}.hex

  • Thank you so much for this solution! I had to use a workaround to pull a docker image separately and then execute "docker run west build" on it. But your solution makes it possible to avoid using docker within docker on each step which shorten my build time from 12 to 3 minutes!

Reply Children
No Data
Related