Is there a way to configure an IDF project when running a GitLab CI/CD pipeline?

Frowly
Posts: 2
Joined: Mon Feb 10, 2020 3:20 pm

Is there a way to configure an IDF project when running a GitLab CI/CD pipeline?

Postby Frowly » Mon Feb 10, 2020 4:14 pm

Hi, I have a configured IDF project in a Git repository on a GitLab server. Configured means I ran

Code: Select all

idf.py menuconfig
and the sdkconfig file is check into the repository. When building (aka running the pipeline) though, I want to assign the value of a GitLab environment variable to an entry that's purposely not been set. Basically I want to "run menuconfig without the interactive ui to set some remaining value".

I could write a simple script and set the entry in sdkconfig directly, but at the top of the file it clearly states:
# Automatically generated file. DO NOT EDIT.
Is there there a tool to do this or how is it usually done?

Thanks,
Frow

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Is there a way to configure an IDF project when running a GitLab CI/CD pipeline?

Postby ESP_Angus » Mon Feb 10, 2020 11:20 pm

Hi Frowly,

Despite the stern warning in the comment, it is possible to edit this file (just need to be careful when doing so). Appending a NAME=VALUE to the end may be enough, depending on what the other settings or requirements are. Or you could use a tool like "sed" to replace the old value with the new value.

If the config variable is one that you've added in your project then to is also possible to define a KConfig entry that says "this entry should have the value of environment variable X", like this:
https://github.com/espressif/esp-idf/bl ... Kconfig#L9


Angus

Frowly
Posts: 2
Joined: Mon Feb 10, 2020 3:20 pm

Re: Is there a way to configure an IDF project when running a GitLab CI/CD pipeline?

Postby Frowly » Fri Feb 14, 2020 11:20 am

Thanks for the quick answer Angus!

Using sed was what I was thinking. So it's nice, that it's actually "allowed" to just replace values in sdkconfig.

The second alternative you described seems very intriguing, though. So I tried it, but it doesn't work properly the way I do it. When I change my Kconfig.projbuild from

Code: Select all

config MY_VARIABLE
        string
to

Code: Select all

config MY_VARIABLE
        string
        option env="MY_VARIABLE"
the value of the environment variable "MY_VARIABLE" appears when running menuconfig, but after closing menuconfig it doesn't get written to sdkconfig. In fact the entire variable doesn't appear. Not even

Code: Select all

CONFIG_MY_VARIABLE=""
without a value. Am I doing something wrong?

Frow

User avatar
thefury
Posts: 17
Joined: Thu Sep 05, 2019 5:25 pm

Re: Is there a way to configure an IDF project when running a GitLab CI/CD pipeline?

Postby thefury » Mon Feb 24, 2020 10:36 pm

Here's what I've put in my component's CMakeLists.txt:

Specifically, the last line
  1. set(COMPONENT_SRCDIRS ". util")
  2. set(COMPONENT_ADD_INCLUDEDIRS ". util")
  3. register_component()
  4. component_compile_definitions(WIFI_SSID="$ENV{WIFI_SSID}" WIFI_PASSWORD="$ENV{WIFI_PASSWORD}" )
Not entirely sure if that's the best way to do it, but it seems to work for me. I have WIFI_SSID and WIFI_PASSWORD defined in GitLab CI/CD variables, and I have it defined in my local environment when building and flashing from a computer. If I need a different value for other environments, I can define environment-specific values in GitLab CI/CD settings as well (the "Scope" column allows you to specify which environment(s) that value should apply to, with * being the default fallback for every other environment that isn't specified)

Who is online

Users browsing this forum: No registered users and 145 guests