Extract current Bundle-Version and use outside of BND

Hi everyone,

I have a bnd workspace with a gradle build around it, that exports a jar in the end. We have a second buildstep on github, that then builds a docker container from it.

I have the goal of using the Bundle-Version of one bundle, as Version of the docker image. Thus, I somehow need a mechanism to extract the Version and I’m a bit at a loss here. Has anybody an Idea what the best way would be? I was thinking about a code generator that produces a properties file that has the final Version. Does anybody have a better solution?

Thanks,

Jürgen.

bnd select -h Bundle-Version ./biz.aQute.bnd.util/generated/biz.aQute.bnd.util.jar

# outputs e.g.
7.3.0.202602042012-SNAPSHOT

# or with assigning it to variable
version=$(bnd select -h Bundle-Version ./biz.aQute.bnd.util/generated/biz.aQute.bnd.util.jar)
echo "Building version $version"

In a script / github action you could install bnd CLI and then run the command above like this: How to install bnd | bnd

Great and Thanks heaps! I will give it a shot.