Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Awk script to get the version info from a Gradle command?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I suggest to replace some_awk_code with awk 'NR==2' or sed '2!d' to get only second row.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading