Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Applying Mark's suggestions from code review
Co-authored-by: Mark Waite <[email protected]>
  • Loading branch information
Queen-esther01 and MarkEWaite authored May 3, 2021
commit 0f1f9a2f6c6e606f21eb1582865200a2d429c782
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
<b>Reporting the current directory of the Pipeline step.</b>
<p><code>sh 'pwd'</code></p>

<b>Making HTTP requests </b>
<p><code>sh "curl -X POST --data-urlencode \'payload=${payload}\' ${slackURL}"</code></p>
<b>Making HTTP requests with curl (scripted Pipeline)</b>
<p><pre>
<code>def payload='payload to send'
def slackURL='https://example.slack.com/archives/CCQU3EHYP'
sh "curl -X POST --data-urlencode \"payload=${payload}\" ${slackURL}"
</code></pre></p>

<b>Running tests in the same workspace that the project was built </b>
<p><code>sh 'mvn test'</code></p>
Expand All @@ -32,7 +36,7 @@
'''
</pre>
</p>
<b>Escaping script content from groovy interpretation </b>>
<b>Escaping script content from groovy interpolation </b>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra trailing >

Suggested change
<b>Escaping script content from groovy interpolation </b>>
<b>Escaping script content from groovy interpolation </b>

<p>The triple-double-quote (""") string literal syntax allows for variable/expression substitution (interpolation), so the backslash (\) is interpreted as a special character "escape".</p>
<p>Since the first open parentheses is not such a special character, Groovy compilation fails. If your intent is to have literal backslashes in the resulting string, you need to escape the backslashes. That is, use a double-backslash (\\) to substitute for one literal backslash</p>
<p><code>sh ("""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that we want to document scripted pipeline, any other opinions for other reviewers ? I would prefer to only have declarative pipeline in help.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be helpful to a few people, i specifically added it because of feedback from a user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a mix of scripted and declarative is most helpful to readers, with preference to use declarative when we can

Expand Down