Way to use api rest call with Test-Harness

41 views
Skip to first unread message

maxim.c...@ingeno.ca

unread,
Feb 17, 2017, 10:17:29 AM2/17/17
to Jenkins Developers
Hey guys, 

       I'm currently writing a gradle plugin that import job/view/folder/pipeline from a job directory to a jenkins instance.

In the plugin i use httpClient, to post/get request that validate if the job exist or create it. I tried my plugin with a local and a cloud instance and it work great, But with the test harness, it looks like the JenkinsRule instance use the same thread than my test and somehow the response from the jenkins jetty instance always give 404.

Do you guys know a way to test restApi based functionality without having to spawn a jenkins docker instance?
Otherwise, a way to have a JenkinsRule Async?

Thanks

Jesse Glick

unread,
Feb 17, 2017, 10:30:12 AM2/17/17
to Jenkins Dev
On Fri, Feb 17, 2017 at 10:17 AM, <maxim.c...@ingeno.ca> wrote:
> somehow the response from the
> jenkins jetty instance always give 404.

Well track down why. Plenty of tests using
`JenkinsRule.createWebClient` successfully.

Maxim Chouinard

unread,
Feb 17, 2017, 10:35:27 AM2/17/17
to jenkin...@googlegroups.com
I will dig in there a bit. I was wondering , if someone had perform that kind of test before.

output from my test:
GET : http://localhost:60768/jenkins/crumbIssuer/api/json 404 [Authorization:Basic YWRtaW46ZDk3MTYwOTZkMzY3YTA3MzI4OWVmNGM4MTFiYjY2MmI=]

manual curl in the console:  
curl -XGET 'http://localhost:60768/jenkins/crumbIssuer/api/json' --user admin:password                                                                                                                                                                                                                 09:06:10
{"_class":"org.jvnet.hudson.test.TestCrumbIssuer","crumb":"test","crumbRequestField":"Jenkins-Crumb"}


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/1z0SDAP4U1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3m7aeBP7dvLXj36mgxoYjSvXksdh3pZ4d30O6FvgRz7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Maxim Chouinard
Java Developer / Ingeno
skype: maxim.chouinard

Jesse Glick

unread,
Feb 17, 2017, 12:34:00 PM2/17/17
to Jenkins Dev
On Fri, Feb 17, 2017 at 10:35 AM, Maxim Chouinard
<maxim.c...@ingeno.ca> wrote:
> output from my test:
> GET : http://localhost:60768/jenkins/crumbIssuer/api/json 404

Why is your test asking for the crumb? See the utilities in
`JenkinsRule.WebClient` to add a crumb to a request for you.

Maxim Chouinard

unread,
Feb 17, 2017, 3:56:17 PM2/17/17
to jenkin...@googlegroups.com
The plugin add jobs via the rest api, so in my integration test i want to use the same behaviour but against a jenkins instance, maybe i should use a dockerized jenkins instead

Jesse Glick

unread,
Feb 17, 2017, 5:02:38 PM2/17/17
to Jenkins Dev
Hold on, you are writing a *Gradle* plugin? Then do not use
`jenkins-test-harness`, this is only for tests of Jenkins plugins.
Reply all
Reply to author
Forward
0 new messages