Cmake plugin failure in Azure Pipelines

Hi all,

I have a cmake-based part which fails to build in Azure Pipelines, even though it works locally with e.g. snapcraft --use-lxd.

This is the specific part:

Azure Pipelines reports the failure as:

2020-03-03T19:49:37.0073842Z Building llvm 
2020-03-03T19:49:37.5146968Z /tmp/snapcraft-5047/run-1.sh: 171: export: agent.jobstatus: bad variable name
2020-03-03T19:49:37.5182580Z cmake /home/vsts/work/1/s/parts/llvm/src/llvm -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-static-libstdc++ -DCOMPILER_RT_INCLUDE_TESTS=OFF -DCOMPILER_RT_USE_LIBCXX=OFF -DLLVM_BINUTILS_INCDIR=/usr/include '-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Mips;MSP430;NVPTX;PowerPC;RISCV;WebAssembly;X86' -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR '-DLLVM_ENABLE_PROJECTS=compiler-rt;lld' -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_INCLUDE_TESTS=OFF -GNinja
2020-03-03T19:49:37.5186661Z Failed to run "cmake /home/vsts/work/1/s/parts/llvm/src/llvm -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-static-libstdc++ -DCOMPILER_RT_INCLUDE_TESTS=OFF -DCOMPILER_RT_USE_LIBCXX=OFF -DLLVM_BINUTILS_INCDIR=/usr/include '-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Mips;MSP430;NVPTX;PowerPC;RISCV;WebAssembly;X86' -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR '-DLLVM_ENABLE_PROJECTS=compiler-rt;lld' -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_INCLUDE_TESTS=OFF -GNinja" for 'llvm': Exited with code 2.
2020-03-03T19:49:37.5188283Z Verify that the part is using the correct parameters and try again.
2020-03-03T19:49:37.5727336Z 
2020-03-03T19:49:37.5790364Z ##[error]Bash exited with code '2'.
2020-03-03T19:49:37.6531284Z ##[section]Finishing: Build ldc2 snap package

Full log here: https://dev.azure.com/ldc-developers/snap/_build/results?buildId=1295&view=logs
And in raw form: https://dev.azure.com/ldc-developers/e8373dcc-baf1-4de3-96d6-27efe4141dc5/_apis/build/builds/1295/logs/6

Does anyone have any suggestion as to what is going wrong? It’s really not obvious to me what could be making the difference, given that it works when I invoke snapcraft on my local machine.

Thanks in advance for any advice or feedback,

   -- Joe

The problem is indicated by this snippet:

export: agent.jobstatus: bad variable name

It looks like snapcraft’s cmake plugin copies the active environment when calling cmake via creating a bash script with export calls followed by the call to cmake and executing that. Bash does not understand environment variables with a dot . as part of the name, like here with agent.jobstatus and therefore throws this error and exits with a non-zero return code.

@sergiusens, @cjp256 is it a good idea to add code in snapcraft/internal/common.py function _run() to filter environment variables that cannot be safely exported by bash?

1 Like

I assumed that was related to it but didn’t know how to interpret the error. Thanks for explaining.

Should I raise a Launchpad issue, or do you have enough to take it from here?

Thanks & best wishes,

-- Joe