Yes, I would still do it like this.
The rest api is meant to be used to control/query Jenkins from the outside 
of Jenkins, e.g. from other services that aren't running in Jenkins.
If you are in groovy inside the Jenkins instance, it's sort of a detour to 
use the rest api.

Look at e.g. the BuildContributorsController.onCompleted method and 
the StandardBuildMetadataContributor, it adds metadata to a build as it 
completes and do something similar in your script.

Br Tomas

On Tuesday, January 3, 2017 at 2:19:22 PM UTC+1, PF66 wrote:
>
> Thanks for the reply.
> As Daniel Beck said, I got the answer yesterday and forgot to update this 
> thread. My mistake.
>
> Resolved by doing this:
>
> MetadataBuildAction metadataBuild = 
> Jenkins.getInstance().getItemByFullName(jobName, 
> Job.class).getBuildByNumber(buildNr).getAction(MetadataBuildAction.class);
>
> if(metadataBuild != null) {
>     Collection<String> metadataNames = metadataBuild.getChildNames();
>
>
> I'm sorry if it might seem trivial but since I'm fairly new to this, I 
> still have to catch all this little nuances.
>
> But still related, how can I do the 'update' of a value on a groovy script 
> inside a pipeline job? 
> I still need to access like this or do a cli/request?
>
>
> terça-feira, 3 de Janeiro de 2017 às 09:45:24 UTC, Tomas Westling escreveu:
>>
>> As Gavin says, if you want to read or manipulate the metadata from a 
>> plugin, you shouldn't use the rest api.
>> For nodes, the metadata is stored as NodeProperties, look at 
>> MetadadataNodeProperty.java.
>> For Jobs and Builds, look at the actions MetadataJobAction.java and 
>> MetadataBuildAction.java, these are available on jobs and builds
>> that have metadata associated with them.
>>
>> Br Tomas
>>
>> Den söndag 1 januari 2017 kl. 17:59:49 UTC+1 skrev PF66:
>>>
>>> On the plugin there is a doGet() and doUpdate() (
>>> https://github.com/jenkinsci/metadata-plugin/blob/0a780cfd6ce11aba43bcd5e220bd3a318f0b33e9/src/main/java/com/sonyericsson/hudson/plugins/metadata/cli/HttpCliRootAction.java
>>> )
>>>
>>> How can I call those inside my own plugin? I'm having trouble create the 
>>> StaplerRequest/Response and process them.
>>> Maybe it isn't this the way to go?
>>>
>>> sábado, 31 de Dezembro de 2016 às 08:43:07 UTC, Gavin Mogan escreveu:
>>>>
>>>> Are you making a plugin to access data from another plugin using the 
>>>> rest API?
>>>>
>>>> I'm on mobile right now so I can't check but I'm pretty sure that 
>>>> plugin like most others will have actions (getActions()) attached to the 
>>>> build. Nothing exposed by rest should be hidden from native interfaces.
>>>>
>>>> If you are just writing a script, it belongs on the users list, but 
>>>> you'll need to create/reuse an existing user. All users will have username 
>>>> and API tokens on thier edit profile page, you should be able to use that 
>>>> to basic authenticate for APIs.
>>>>
>>>> Gavin
>>>>
>>>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/1b36b132-1f1c-462f-8f1e-43e108673547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to