Check 
https://github.com/jenkinsci/credentials-plugin/blob/master/docs/consumer.adoc 
for how to access credentials from a plugin.

Björn
[email protected] schrieb am Donnerstag, 20. Mai 2021 um 13:45:30 UTC+2:

> I want to read a particular user name added in the config.xml under  
> "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl" 
> tag for now but later I may require to read other values as well.  I was 
> trying to retrieve the xml first, parse it and then read the value.  Below 
> is the further explanation of my requirement.
>
> In my Jenkins instance, the jobs are organized in folders. There are 
> credentials being added in the folder configuration which I can see by 
> accessing the URL for the config.xml. Then I have another event publisher 
> plugin where I need the username from the folder configuration. I initially 
> thought that the username can be extracted by parsing the config.xml file 
> and I am not aware of any way to get this information in the event 
> publisher plugin and I am not sure how to use Java API to access this value 
> without retrieving the xml. Could you please elaborate how Java API can be 
> be used to read the desire value? Can anyone please provide me some 
> guidance regarding this?
>
> On Wednesday, 19 May 2021 at 18:45:17 UTC+5:30 [email protected] wrote:
>
>>
>> Am 19.05.2021 um 11:42 schrieb HALLEY SALAM <[email protected]>:
>>
>> Greetings,
>>
>> I am new to Jenkins and just started contributing to developing a plugin 
>> for Jenkins where I need to extract some values from the job config.xml. 
>>
>> What do you want to read?
>>
>>
>> I am able to retrieve the config.xml with the below approaches:
>>
>>    1. Accessing through /config.xml
>>    2. By creating Jenkins client and invoking getJobXml() method passing 
>>    the job name
>>
>>
>> Both approaches are wrong. Please use the Java API to access the values 
>> from the corresponding Java objects. The XML representation is an internal 
>> structure that should not be read by some other tool. 
>>
>> But in both the cases I need to pass the Jenkins credentials which shall 
>> not be the case since I am trying to access from within the running Jenkins 
>> instance. And also above approaches can be implemented in any external 
>> project if one knows the credentials to access the Jenkins instance. I want 
>> an approach which shall be bound within the plugin meaning I shall be able 
>> to read the config.xml via the job name without providing any credentials.
>>
>> Could anyone provide me the best solution to read the config.xml within 
>> the java code? Any assistance is highly appreciated. Thank you in advance.
>>
>> Regards,
>> Halley
>>
>> -- 
>> 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/CA%2BNFquB7XvRo_8rG1C0Qn3J74vvc6%3D41ABytJSZ2eW1_JoHo3Q%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-dev/CA%2BNFquB7XvRo_8rG1C0Qn3J74vvc6%3D41ABytJSZ2eW1_JoHo3Q%40mail.gmail.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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/8e940e70-1a82-477d-bd9f-3df569d13a9cn%40googlegroups.com.

Reply via email to