'Awk script to get the version info from a Gradle command? [closed]

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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source