I have a Gradle task that prints out the artifact version, like this
$ ./gradlew :myproject:printVersion
:myproject:printVersion
2.0
BUILD SUCCESSFUL
Total time: 0.976 secs
What's an awk
or shell task to get the 2.0
part that I can use in a Jenkins pipeline? Note currently the artifact version is 2.0
, but can change later to, say, 2.1
, or 3.0
etc.
$ ./gradlew :myproject:printVersion | some_awk_code
I suggest to replace some_awk_code
with awk 'NR==2'
or sed '2!d'
to get only second row.