Re: How to use the credentials API properly

2016-10-15 Thread Stephen Connolly
On Saturday 15 October 2016, Péter Major <majorpe...@gmail.com> wrote:

> Hi,
>
> I'm having some troubles trying to integrate the hipchat-plugin with the
> credentials-plugin, and I'm quite confused about how to use the credentials
> API properly.
> Any help with any of these questions would be much appreciated:
>
> 1) The JavaDoc on AbstractIdCredentialsListBoxModel contains a few
> non-compiling examples, but other than that it appears to suggest that it
> is best practice to display the current value. What is problematic though
> is that the only way I can obtain the current value of the credentialId is
> that I add it to my doFill method as a @QueryParameter. However this
> results in a bug: if you have a non-default value selected when you load
> the page, the first time you try to change it to -none- it will display the
> original selection again. From what I can tell this was related to some
> fillDependsOn related AJAX calls which meant that doFill was called twice,
> once with credentialId "" and once with "originalValue".
>
> // I think this bug also means that if you have the QueryParameter
> defined, right after successfully selecting the new value, it will display
> -current- instead of the freshly selected value.
> Now this clearly sounds like a bug, but I don't know what other thing I
> can do about it than just remove the credentialId parameter from my doFill
> method. But then that leads to my second problem..
>

Could you create a JIRA with a sample showing the behaviour you describe


>
> 2) If you have the credential as a jelly field both at job level and at
> global level, then for some reason the doFill method in the static
> Descriptor impl will be called for both cases. Whilst that works nicely in
> the global config case (since I can access DescriptorImpl fields just
> fine), I can't access the configured value at the job level no matter what
> I do. Adding the credentialId as a QueryParameter would resolve this
> problem, but then I'm back to the strange update bug at 1).
>

You need to use ancestor in path to find the Item in context


>
> Is there a possibility to define the doFill method at the Publisher level
> for my job level credential setting?
>

> 3) Although the doFill methods give you great control over what
> credentials to display, I didn't really find anything about how to control
> the Add button in terms of how to only allow the addition of a particular
> credential type only (e.g if I only want to use Secret text type of
> credential, Add shouldn't suggest creating an SSH key credential). Is this
> even possible?
>

You cannot control the add button at this point in time... the add dialogue
was messy enough to get working for contexts ;-)


>
> Thanks in advance,
> Peter
>
> --
> 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
> <javascript:_e(%7B%7D,'cvml','jenkinsci-dev%2bunsubscr...@googlegroups.com');>
> .
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-dev/714cfaef-e0f5-4966-8c41-2ceffccf4b9e%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/714cfaef-e0f5-4966-8c41-2ceffccf4b9e%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Sent from my phone

-- 
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/CA%2BnPnMzguXitnvnFSaku439%2BsW6GsrgX%3DeCV9Y9SH1mWoCspJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to use the credentials API properly

2016-10-15 Thread Péter Major
Hi,

I'm having some troubles trying to integrate the hipchat-plugin with the 
credentials-plugin, and I'm quite confused about how to use the credentials 
API properly.
Any help with any of these questions would be much appreciated:

1) The JavaDoc on AbstractIdCredentialsListBoxModel contains a few 
non-compiling examples, but other than that it appears to suggest that it 
is best practice to display the current value. What is problematic though 
is that the only way I can obtain the current value of the credentialId is 
that I add it to my doFill method as a @QueryParameter. However this 
results in a bug: if you have a non-default value selected when you load 
the page, the first time you try to change it to -none- it will display the 
original selection again. From what I can tell this was related to some 
fillDependsOn related AJAX calls which meant that doFill was called twice, 
once with credentialId "" and once with "originalValue".

// I think this bug also means that if you have the QueryParameter defined, 
right after successfully selecting the new value, it will display -current- 
instead of the freshly selected value.
Now this clearly sounds like a bug, but I don't know what other thing I can 
do about it than just remove the credentialId parameter from my doFill 
method. But then that leads to my second problem..

2) If you have the credential as a jelly field both at job level and at 
global level, then for some reason the doFill method in the static 
Descriptor impl will be called for both cases. Whilst that works nicely in 
the global config case (since I can access DescriptorImpl fields just 
fine), I can't access the configured value at the job level no matter what 
I do. Adding the credentialId as a QueryParameter would resolve this 
problem, but then I'm back to the strange update bug at 1).

Is there a possibility to define the doFill method at the Publisher level 
for my job level credential setting?

3) Although the doFill methods give you great control over what credentials 
to display, I didn't really find anything about how to control the Add 
button in terms of how to only allow the addition of a particular 
credential type only (e.g if I only want to use Secret text type of 
credential, Add shouldn't suggest creating an SSH key credential). Is this 
even possible?

Thanks in advance,
Peter

-- 
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/714cfaef-e0f5-4966-8c41-2ceffccf4b9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.