Is that exported bean a java class or a shared library groovy class?

i feel like stapler only checks classes on startup or something?

Gavin

On Wed, Dec 15, 2021 at 9:31 AM Oscar Arevalo Loyola <osarl...@gmail.com>
wrote:

> Thanks for your response.
>
> Yes, I implemented the method in my class.
>
> My test code looks like:
>
> import hudson.model.Action
> import hudson.model.Api
> import org.kohsuke.stapler.export.ExportedBean
> import org.kohsuke.stapler.export.Exported
>
> @ExportedBean
> public class myAction implements Action {
>
>     private String name;
>
>     public Api getApi() {
>         return new Api(this);
>     }
>
>     public myAction(String name) {
>         this.name = name;
>     }
>
>     @Exported
>     public String getName() {
>         return name;
>     }
>
>     @Override
>     public String getIconFileName() {
>         return null;
>     }
>
>     @Override
>     public String getDisplayName() {
>         return null;
>     }
>
>     @Override
>     public String getUrlName() {
>         return null;
>     }
> }
>
> Then from the pipeline:
>
> currentBuild.rawBuild.addAction(new myAction("actionName"))
>
> In the api/json response I see myAction:
>
> { "_class": "myAction" },
>
> but no properties exposed.
>
> I tried defining visibility in @Exported and also increasing depth in the
> api request but didn't work.
>
> El miércoles, 15 de diciembre de 2021 a la(s) 03:17:04 UTC-8,
> ullrich...@gmail.com escribió:
>
>> Does your action implement a method:
>>
>> public Api getApi();
>>
>> ?
>>
>> Am 15.12.2021 um 02:12 schrieb Oscar Arevalo Loyola <osar...@gmail.com>:
>>
>> Hi,
>>
>> I'm trying to expose internal Run data to the REST API.
>> Currently I'm using a Shared Library to create an object containing data
>> about downstream builds in multiple levels
>>
>> Is it possible to expose the data to the REST API from Shared library
>> code?
>> I was checking several methods but still not able to achieve it.
>> So, I tried with Run.addAction and I'm able to see my action in in the
>> url/api/json but it doesn't expose the properties of my action (I added
>> @ExportedBean to the class and @Exported to the properties)
>>
>> Basically, I want to achieve this:
>>
>> https://wiki.jenkins-ci.org/display/JENKINS/Exposing+data+to+the+remote+API
>> but from a Shared Library, not from a plugin.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to jenkinsci-de...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-dev/7997e32b-cf5f-42a2-8879-880fbaa11d44n%40googlegroups.com
>> <https://groups.google.com/d/msgid/jenkinsci-dev/7997e32b-cf5f-42a2-8879-880fbaa11d44n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/4406950c-ae2f-4533-bc19-539f5173c70dn%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/4406950c-ae2f-4533-bc19-539f5173c70dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_Duv1u13AHkizXxumAZ8dk1e4-4ZaPiFbv3V-zT%2B90_EmUQ%40mail.gmail.com.

Reply via email to