1

I want to grep the result of a maven (maven-help plugin) command and store the grep result in a shell variable and use it in .gitlab-ci.yml file.

I've tried this and the maven command prints the desired result, but echo $VERSION prints nothing (i.e. VERSION variable is empty):

VERSION= mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version

I've also tried this and it gets error: Downloading:: command not found:

VERSION= $(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate "-Dexpression=project.version" | grep -v '\[')

So how can i store the grep result in a variable?

AshKan
  • 779
  • 2
  • 8
  • 22
  • Possible duplicate of [assigning the output of a command to a variable in a shell script](https://stackoverflow.com/questions/20688552/assigning-the-output-of-a-command-to-a-variable-in-a-shell-script) – Benjamin W. Jan 18 '18 at 19:43

1 Answers1

0

Remove the space after the =, that is:

VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate "-Dexpression=project.version")
JFMR
  • 23,265
  • 4
  • 52
  • 76