-
Notifications
You must be signed in to change notification settings - Fork 105
Improvement: Add Examples To sh Step [JENKINS-65396] #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
021ec66
1e9657f
6cf1fce
1cf016f
0f1f9a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Mark Waite <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
|
|
@@ -32,7 +36,7 @@ | |
| ''' | ||
| </pre> | ||
| </p> | ||
| <b>Escaping script content from groovy interpretation </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 (""" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra trailing
>