2

I have an execute shell in Jenkins:

export MYVAR
MYVAR=echo $JiraReleaseNotes | sed 's/\[/<br>\[/g'
echo MYVAR=$MYVAR >> ./AndroidStable/App/config.properties

What I'm trying to do is replace all "[" values with "[br>" at $JiraReleaseNotes and set them to MYVAR and then copy the content to config.properties file.

But I get an error in second line:

Relase: command not found

Which Relase is the first word in $JiraReleaseNotes, why it thinks it is a command?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Dim
  • 4,527
  • 15
  • 80
  • 139
  • 2
    If you want to execute a command, you need to use `var=$(command)`. Currently you are saying `MYVAR=echo Relase ...` so this tries to execute the command `Relase` after setting the variable `MYVAR` to `echo`. See [Bash script variable declaration - command not found](http://stackoverflow.com/a/2268117/1983854) for a great description of this. – fedorqui Jul 07 '16 at 14:11
  • Possible duplicate of [Bash script variable declaration - command not found](http://stackoverflow.com/questions/2268104/bash-script-variable-declaration-command-not-found) – BitwiseMan Jul 08 '16 at 09:18

1 Answers1

0

Explanation:

You need to execute the desired command echo $JiraReleaseNotes | sed 's/\[/<br>\[/g' within brackets first before it can be assigned to a variable. As mentioned in the comments by Fedorqui earlier, it will look like so

MYVAR=$(results_of_this_command)

in this case results_of_this_command or echo $JiraReleaseNotes | sed 's/\[/<br>\[/g' will be executed first, with the result of it then being assigned to be theMYVAR variable

CODE:

MYVAR=$(echo $JiraReleaseNotes | sed 's/\[/<br>\[/g')
echo "MYVAR=$MYVAR" >> ./AndroidStable/App/config.properties
Community
  • 1
  • 1
KeithC
  • 436
  • 1
  • 6
  • 25