My snap pulls a repo as part of build process. I would like to have a way to set the git branch dynamically while building. Is there a way to get a additional parameter passed during snapcraft build step. Or is there a way to get an environment variable inside snapcraft.yaml?
Hm, I’m not entirely sure what you’re asking here. Who or what decides which branch to use? Does the person or tool executing snapcraft decide that? Or do you have another part or a previous step which decides it during the execution of snapcraft.
Both developers and tool executing snapcraft would pass on the branch environment.
if we had another part which gets the environment variable via script, all snaps needs to run this script before any pull. Do you have any startup option like after.
It would be nice to have environment variables accessed in snapcraft.yaml
That’s clear thanks, you basically want the “parameterized builds” feature from Jenkins.
As far as I know, this is not yet supported. It might be useful for you to create a request for this feature here: https://bugs.launchpad.net/snapcraft/+filebug and link back to this thread for more context.
I can think of a few workarounds:
Have a makefile or script which changes snapcraft.yaml to point to the requested branch.
Have multiple snapcraft.yaml files, possibly generated from a single template.