-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding multibranch example with credentials
- Loading branch information
1 parent
194ee0c
commit a3b0024
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* curl -X POST -H "Content-Type: application/json" -H "headerWithNumber: nbr123" -H "headerWithString: a b c" -d '{ "before": "1848f12", "after": "5cab1", "ref": "refs/heads/develop" }' -vs http://admin:admin@localhost:8080/jenkins/generic-webhook-trigger/invoke?requestWithNumber=nbr%20123\&requestWithString=a%20string | ||
*/ | ||
node { | ||
|
||
withCredentials([string(credentialsId: 'mycredentialsid', variable: 'credentialsVariable')]) { | ||
properties([ | ||
pipelineTriggers([ | ||
[$class: 'GenericTrigger', | ||
genericVariables: [ | ||
[key: 'reference', value: '$.ref'], | ||
[ | ||
key: 'before', | ||
value: '$.before', | ||
expressionType: 'JSONPath', //Optional, defaults to JSONPath | ||
regexpFilter: '', //Optional, defaults to empty string | ||
defaultValue: '' //Optional, defaults to empty string | ||
] | ||
], | ||
genericRequestVariables: [ | ||
[key: 'requestWithNumber', regexpFilter: '[^0-9]'], | ||
[key: 'requestWithString', regexpFilter: ''] | ||
], | ||
genericHeaderVariables: [ | ||
[key: 'headerWithNumber', regexpFilter: '[^0-9]'], | ||
[key: 'headerWithString', regexpFilter: ''], | ||
[key: 'X-GitHub-Event', regexpFilter: ''] | ||
], | ||
token: credentialsVariable, | ||
printContributedVariables: true, | ||
printPostContent: true, | ||
regexpFilterText: '', | ||
regexpFilterExpression: '' | ||
] | ||
]) | ||
]) | ||
} | ||
|
||
|
||
stage("build") { | ||
sh ''' | ||
echo Variables from shell: | ||
echo reference $reference | ||
echo before $before | ||
echo requestWithNumber $requestWithNumber | ||
echo requestWithString $requestWithString | ||
echo headerWithNumber $headerWithNumber | ||
echo headerWithString $headerWithString | ||
echo X_GitHub_Event $X_GitHub_Event | ||
''' | ||
} | ||
} |