1

I would like to add some labels (commit hash, branch name,...) to images I create using Openshift source-to-image binary build. These labels will have naturally different values for every build.

Currently oc start-build does not even support -e flags to add environment variables. (At least is seems to, it works for Git source, its a bug?)

And for binary build does not supports --build-arg to pass argument for docker file.

The only way I was able to accomplish this to call oc set env bc [build-name] then start the build. And use Label in Dockerfile with values from environment variables.

My question is isn't there a better way to do this? (Ideally in a way that Dockerfile is not necessarily changed) Doesn't s2i supports passing --label to docker build behind?

Thank you.

Daein Park
  • 4,393
  • 2
  • 12
  • 21
csviri
  • 1,159
  • 3
  • 16
  • 31

1 Answers1

0

Do you want to add environment variable when you start oc start-build ? Because you mentioned oc set env bc [build-name]. Then you can use --env=<key>=<value> option, refer Starting Build for more details.

$ oc start-build <buildconfig_name> --env=<key>=<value>

I hope it help you.

Daein Park
  • 4,393
  • 2
  • 12
  • 21
  • 1
    yes, that would be a little bit nicer solution. But --env / -e does not work for binary build for some reason - will create issue in github for them. (It works for Git source builds :O) – csviri May 31 '19 at 09:07