Re: String manipulation in sh block

2017-09-24 Thread Idan Adar
Okay, got it at last.
The backslashes weren't needed.

version=$(jq \".version\" package.json | tr -d '\"')



On Sunday, September 24, 2017 at 3:27:15 PM UTC+3, Idan Adar wrote:

> Appreciate help with getting the following block right (I always get 
> confused with strings and double/single/escaped quotes):
>
> Right now the below puts the message "Bump version number (${version}) 
> [ci skip]" in the commit message.
> The wanted result is for ${version} to actually be the extracted version 
> number rather than the variable name as-is...
>
> sshagent (credentials: ['...']) {
>sh '''
>   git clone -b master git@github.***.git
>   ...
>   ...
>   version=$(jq \".version\" package.json | tr -d '\"')
>   git commit -am "Bump version number (${version}) [ci skip]"
>   git push origin master
>'''
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8b88c81a-9f63-4f9e-821b-8aba0dee1dd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


String manipulation in sh block

2017-09-24 Thread Idan Adar
Appreciate help with getting the following block right (I always get 
confused with strings and double/single/escaped quotes):

Right now the below puts the message "Bump version number (${version}) [ci 
skip]" in the commit message.
The wanted result is for ${version} to actually be the extracted version 
number rather than the variable name as-is...

sshagent (credentials: ['...']) {
   sh '''
  git clone -b master git@github.***.git
  ...
  ...
  version=$(jq \".version\" package.json | tr -d '\"')
  git commit -am "Bump version number (${version}) [ci skip]"
  git push origin master
   '''
}

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/154e8398-5643-4919-9029-71e263d94f00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.