Revisions
-
Faheetah revised this gist
Sep 28, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,8 @@ node { sh 'echo \\"$BUILD_NUMBER\\"' // "1" echo 'Using three backslashes still results in only preserving the quotes' sh 'echo \\\"$BUILD_NUMBER\\\"' // "1" echo 'To end up with \" use \\\\\\" (yes, six backslashes)' sh 'echo \\\\\\"$BUILD_NUMBER\\\\\\"' echo 'This is fine and all, but we cannot substitute Jenkins variables in single quote strings' def foo = 'bar' sh 'echo "${foo}"' // (returns nothing) -
Faheetah revised this gist
Sep 28, 2018 . 1 changed file with 13 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,31 @@ node { echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1' echo 'No quotes, pipeline command in single quotes' sh 'echo $BUILD_NUMBER' // 1 echo 'Double quotes are silently dropped' sh 'echo "$BUILD_NUMBER"' // 1 echo 'Even escaped with a single backslash they are dropped' sh 'echo \"$BUILD_NUMBER\"' // 1 echo 'Using two backslashes, the quotes are preserved' sh 'echo \\"$BUILD_NUMBER\\"' // "1" echo 'Using three backslashes still results in only preserving the quotes' sh 'echo \\\"$BUILD_NUMBER\\\"' // "1" echo 'To end up with \" use \\\\\\\" (yes, seven backslashes)' sh 'echo \\\\\\\"$BUILD_NUMBER\\\\\\\"' echo 'This is fine and all, but we cannot substitute Jenkins variables in single quote strings' def foo = 'bar' sh 'echo "${foo}"' // (returns nothing) echo 'This does not interpolate the string but instead tries to look up "foo" on the command line, so use double quotes' sh "echo \"${foo}\"" // bar echo 'Great, more escaping is needed now. How about just concatenate the strings? Well that gets kind of ugly' sh 'echo \\\\\\"' + foo + '\\\\\\"' // \"bar\" echo 'We still needed all of that escaping and mixing concatenation is hideous!' echo 'There must be a better way, enter dollar slashy strings (actual term)' def command = $/echo \\\"${foo}\\\"/$ sh command // \"bar\" echo 'String interpolation works out of the box as well as environment variables, escaped with double dollars' def vash = $/echo \\\"$$BUILD_NUMBER\\\" ${foo}/$ sh vash // \"3\" bar echo 'It still requires escaping the escape but that is just bash being bash at that point' echo 'Slashy strings are the closest to raw shell input with Jenkins, although the non dollar variant seems to give an error but the dollar slash works fine' } -
Faheetah revised this gist
Sep 28, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,4 +27,5 @@ node { sh vash echo 'It still requires escaping the escape but that is just bash being bash at that point' echo 'Slashy strings are the closest to raw shell input with Jenkins, although the non dollar variant seems to give an error but the dollar slash works fine' echo 'Also of note, percent signs need to be escaped as well, for example 100%% will print a single percent sign after the 100' } -
Faheetah revised this gist
May 21, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ node { echo 'No quotes, pipeline command in single quotes' sh 'echo $BUILD_NUMBER' echo 'Double quotes are silently dropped' sh 'echo "$BUILD_NUMBER"' @@ -9,7 +9,7 @@ node { sh 'echo \\"$BUILD_NUMBER\\"' echo 'Using three backslashes still results in preserving the single quotes' sh 'echo \\\"$BUILD_NUMBER\\\"' echo 'To end up with \" use \\\\\\\" (yes, seven backslashes)' sh 'echo \\\\\\"$BUILD_NUMBER\\\\\\"' echo 'This is fine and all, but we cannot substitute Jenkins variables in single quote strings' def foo = 'bar' -
nowayride revised this gist
May 12, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ node { echo 'Great, more escaping is needed now. How about just concatenate the strings? Well that gets kind of ugly' sh 'echo \\\\\\"' + foo + '\\\\\\"' echo 'We still needed all of that escaping and mixing concatenation is hideous!' echo 'There must be a better way, enter dollar slashy strings (actual term)' def command = $/echo \\\"${foo}\\\"/$ sh command echo 'String interpolation works out of the box as well as environment variables, escaped with double dollars' -
nowayride revised this gist
May 12, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,9 +5,9 @@ node { sh 'echo "$BUILD_NUMBER"' echo 'Even escaped with a single backslash they are dropped' sh 'echo \"$BUILD_NUMBER\"' echo 'Using two backslashes, the quotes are preserved' sh 'echo \\"$BUILD_NUMBER\\"' echo 'Using three backslashes still results in preserving the single quotes' sh 'echo \\\"$BUILD_NUMBER\\\"' echo 'To end up with \" use \\\\\\\" (yes, seven backticks)' sh 'echo \\\\\\"$BUILD_NUMBER\\\\\\"' -
nowayride revised this gist
May 12, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,11 +5,11 @@ node { sh 'echo "$BUILD_NUMBER"' echo 'Even escaped with a single backslash they are dropped' sh 'echo \"$BUILD_NUMBER\"' echo 'Using \\" the quotes are preserved' sh 'echo \\"$BUILD_NUMBER\\"' echo 'Using \\\\\\\" still results in preserving the single quotes' sh 'echo \\\"$BUILD_NUMBER\\\"' echo 'To end up with \" use \\\\\\\" (yes, seven backticks)' sh 'echo \\\\\\"$BUILD_NUMBER\\\\\\"' echo 'This is fine and all, but we cannot substitute Jenkins variables in single quote strings' def foo = 'bar' -
nowayride created this gist
May 12, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ node { echo 'No quotes in single backticks' sh 'echo $BUILD_NUMBER' echo 'Double quotes are silently dropped' sh 'echo "$BUILD_NUMBER"' echo 'Even escaped with a single backslash they are dropped' sh 'echo \"$BUILD_NUMBER\"' echo 'Using \\\\\" the quotes are preserved' sh 'echo \\"$BUILD_NUMBER\\"' echo 'Using \\\\\\\" still results in preserving the single quotes' sh 'echo \\\"$BUILD_NUMBER\\\"' echo 'To end up with \\\" use \\\\\\\\\\\\\" (yes, six backticks) plus one for the double quote' sh 'echo \\\\\\"$BUILD_NUMBER\\\\\\"' echo 'This is fine and all, but we cannot substitute Jenkins variables in single quote strings' def foo = 'bar' sh 'echo "${foo}"' echo 'This does not interpolate the string but instead tries to look up "foo" on the command line, so use double quotes' sh "echo \"${foo}\"" echo 'Great, more escaping is needed now. How about just concatenate the strings? Well that gets kind of ugly' sh 'echo \\\\\\"' + foo + '\\\\\\"' echo 'We still needed all of that escaping and mixing concatenation is hideous!' echo 'There must be a better way, enter slashy strings (actual term)' def command = $/echo \\\"${foo}\\\"/$ sh command echo 'String interpolation works out of the box as well as environment variables, escaped with double dollars' def vash = $/echo \\\"$$BUILD_NUMBER\\\" ${foo}/$ sh vash echo 'It still requires escaping the escape but that is just bash being bash at that point' echo 'Slashy strings are the closest to raw shell input with Jenkins, although the non dollar variant seems to give an error but the dollar slash works fine' }