aitorhh
aitorhh

Reputation: 2451

How to get version from sbt-dynver on command line?

In order to generate dynamically the version in my sbt project I am using the sbt-dynver plugin. But in order to integrate the build system, I would like to obtain the version string from a bash script, something like:

DYNVER=`sbt dynver`

But the previous command does not return anything.

Upvotes: 3

Views: 650

Answers (2)

Przemek Piotrowski
Przemek Piotrowski

Reputation: 7456

The simplest solution is to ignore other SBT output by taking last line. Also it's better to print out version instead of dynver as it affects overrides from your version.sbt file.

VERSION=$(sbt 'print version' | tail -n 1)
echo $VERSION
0.1.7-2-6853afe4

Upvotes: 1

aitorhh
aitorhh

Reputation: 2451

I managed to get what I wanted by adding the 'show' command to sbt and parsing the output value, as follows:

VERSION=`sbt "show dynver" | grep -oE "\w{7}-\w{8}-\w{4}"`
echo $VERSION
4bbbb2a-20171022-1508

Upvotes: 1

Related Questions