Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Generate variable value from command output

Swanthe Lindgren February 13, 2020

I try to extract the project.version from my maven project pom file using the help plug-in and assign it to a variable so I can use it to push my docker image.

 

- step:
  script: # Modify the commands below to build your repository.
    - POM_VERSION='mvn help:evaluate -Dexpression=project.version -q -DforceStdout'
    - echo "version ${POM_VERSION}"

 

But all I get in my log is

version mvn help:evaluate -Dexpression=project.version -q -DforceStdout

 

When I expected to get

version 1.0.4

 

 

How can I get the command output assigned to a variable?

1 answer

0 votes
Swanthe Lindgren February 13, 2020

Think I finally found it by trail and error

 

export POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

echo "version $POM_VERSION"

 

version 1.0.4

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events