Skip to content

Commit

Permalink
Merge remote-tracking branch 'pdalpra/http-request-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
daspilker committed Jul 18, 2016
2 parents ac773b9 + 00a206f commit 4280a67
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
* Added a `SEED_JOB` script variable which provides access to the seed job,
see [Job DSL Commands](Job-DSL-Commands#seed-job)
* Removed anything that has been deprecated in 1.42, see [Migration](Migration#migrating-to-142)
* Enhanced support for the [HTTP Request Plugin](https://wiki.jenkins-ci.org/display/JENKINS/HTTP+Request+Plugin)
* 1.48 (June 24 2016)
* Added option to ignore missing DSL script files or empty wildcards
([JENKINS-34060](https://issues.jenkins-ci.org/browse/JENKINS-34060))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HttpRequestContext implements Context {
String authentication
Boolean returnCodeBuildRelevant
Boolean logResponseBody
Boolean passBuildParameters

/**
* Sets the HTTP method to use. Must be one of {@code 'GET'}, {@code 'POST'}, {@code 'PUT'} or {@code 'DELETE'}.
Expand Down Expand Up @@ -40,4 +41,13 @@ class HttpRequestContext implements Context {
void logResponseBody(boolean logResponseBody = true) {
this.logResponseBody = logResponseBody
}

/**
* Allows to pass build parameters to the request URL. Defaults to {@code false}.
*
* @since 1.49
*/
void passBuildParameters(boolean passBuildParameters = true) {
this.passBuildParameters = passBuildParameters
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,16 @@ class StepContext extends AbstractExtensibleContext {
*
* @since 1.28
*/
@RequiresPlugin(id = 'http_request')
@RequiresPlugin(id = 'http_request', minimumVersion = '1.8.7')
void httpRequest(String requestUrl, @DslContext(HttpRequestContext) Closure closure = null) {
HttpRequestContext context = new HttpRequestContext()
ContextHelper.executeInContext(closure, context)

stepNodes << new NodeBuilder().'jenkins.plugins.http__request.HttpRequest' {
url(requestUrl)
if (context.passBuildParameters != null) {
passBuildParameters(context.passBuildParameters)
}
if (context.httpMode != null) {
httpMode(context.httpMode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ class StepContextSpec extends Specification {
children().size() == 1
url[0].value() == 'http://www.example.com'
}
1 * jobManagement.requirePlugin('http_request')
1 * jobManagement.requireMinimumPluginVersion('http_request', '1.8.7')
}

def 'call http request with all options'() {
Expand All @@ -2948,7 +2948,7 @@ class StepContextSpec extends Specification {
returnCodeBuildRelevant[0].value() == true
logResponseBody[0].value() == true
}
1 * jobManagement.requirePlugin('http_request')
1 * jobManagement.requireMinimumPluginVersion('http_request', '1.8.7')
}

def 'call http request with invalid HTTP mode'() {
Expand All @@ -2975,7 +2975,7 @@ class StepContextSpec extends Specification {
url[0].value() == 'http://www.example.com'
httpMode[0].value() == mode
}
1 * jobManagement.requirePlugin('http_request')
1 * jobManagement.requireMinimumPluginVersion('http_request', '1.8.7')

where:
mode << ['GET', 'POST', 'PUT', 'DELETE']
Expand Down

0 comments on commit 4280a67

Please sign in to comment.