Skip to main content

Hudson Remote API Access Problem

No replies
sanjoygh
Offline
Joined: 2011-09-14
Points: 0

Hi

We are trying to develop Hudson plugin which will expose remote api via http. We started working with HelloWorldBuilder and added new java file for this purpose. Our code is given below:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.MyProject.hudson.listeners;

import hudson.Plugin;
import hudson.model.Api;
import hudson.model.Hudson;
import hudson.model.ModelObject;

/**
*
* @author sanjoyg
*/
public class RemoteApiExample extends Plugin implements ModelObject {

@Override
public String getDisplayName() {
return "Remote API Example";
}

@org.kohsuke.stapler.export.ExportedBean(defaultVisibility = 999)
public static class Entity {

public Api getApi() {
return new Api(this);
}

@org.kohsuke.stapler.export.Exported
public String getMyAttr() {
System.out.println("returning getMyAttr");
return "myvalue";
}
}

public Entity getEntity() {
System.out.println("getEntity");
return new Entity();
}
}

But after installing the plugin whenever we are trying to access the plugin, we receive the HTTP 404 Not found error. The error details :
404 Not Found
Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request

-> evaluate(<hudson.model.Hudson@f67683> :hudson.model.Hudson,"/plugin/remote-api-example/entity/api/xml")
-> evaluate(((StaplerProxy)<hudson.model.Hudson@f67683>).getTarget(),"/plugin/remote-api-example/entity/api/xml")
-> evaluate(<hudson.model.Hudson@f67683>.getPlugin("remote-api-example"),"/entity/api/xml")
-> unexpected null!

If this 404 is unexpected, double check the last part of the trace to see if it should have evaluated to null.

Do we need to add any additional setting in the .jelly files available under the resources\HelloWorldBuilder plugin?

Regards
Sanjoy Ghosh