get global parameter from other plugin

39 views
Skip to first unread message

Shurik

unread,
Jun 2, 2016, 4:59:25 AM6/2/16
to Jenkins Developers
Hi,

I have my plugin (A) that need to get global parameter that define by other plugin (B).

I need that "A" descriptor will be able to get parameter of "B" descriptor ( via getter method )

How I can do it ?

Thanks,
Shurik

Robert Sandell

unread,
Jun 2, 2016, 5:40:31 AM6/2/16
to jenkin...@googlegroups.com
What do you mean by parameter, and in what context do you want it?

--
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/9fe48a9a-32ed-43cf-9320-4d882f03ca42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Shurik

unread,
Jun 2, 2016, 6:32:20 AM6/2/16
to Jenkins Developers
In plugin "B" in global.jelly defined 

<f:entry title="local url" field="localUrl" >
      <f:textbox />
</f:entry>

My plugin is build step and I need ability in my plugin "A" somehow to get the value of localUrl parameter.
I need it in DescriptorImpl inner class.

Baptiste Mathus

unread,
Jun 2, 2016, 8:29:03 AM6/2/16
to Jenkins Developers
I suspect what Robert is (also) asking was more actually a use case than /just/ a technical description on what you currently want to do.

At least, I guess we'll need to know more precisely what you're trying to achieve from a high level PoV to be able to help you correctly.
Possibly, you want to have a look at https://wiki.jenkins-ci.org/display/JENKINS/Dependencies+among+plugins as a starting point.

Possibly, also, the right solution and the more common/standard might be to actually define an extension point in B so that A can register something against it. But again, it will depend on your use case.

Cheers

Shurik

unread,
Jun 2, 2016, 9:01:47 AM6/2/16
to Jenkins Developers, m...@batmat.net
I will try to explain:

I have the below build step code.

public class MyPluginBuilder extends Builder {
private final List<MyFlow> myFlows;
...............
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
{
for (MyFlow currentFlow : this.myFlows) {
}
return true;
}
@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
}
@Extension
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
private String localUrls;
public String getDisplayName() {
return "My Flows";
}
public ListBoxModel getLocalUrlsList(String value) {
ListBoxModel listModel = new ListBoxModel();
for (String currentUrl : localUrls.split("\n")) {
listModel.add(new Option(currentUrl, currentUrl, currentUrl.equals(value)));
}
return listModel;
}
}
}

And I have MyFlow class definition as below

public abstract class MyFlow extends AbstractDescribableImpl<MyFlow>
{
public abstract static class MyFlowDescriptor extends Descriptor<MyFlow>
{
public MyFlowDescriptor() 
{
load();
}
}
}
In MyFlow config.jelly I need to have dropdown list with the values from getLocalUrlsList method of MyPluginBuilder class.

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:entry field="url" title="Urls">
     <f:select />
   </f:entry>
</j:jelly> 


So, I try to find the way how I can fill the dropdown list based on getLocalUrlsList.

Robert Sandell

unread,
Jun 2, 2016, 10:26:26 AM6/2/16
to jenkin...@googlegroups.com

Shurik

unread,
Jun 5, 2016, 11:17:06 AM6/5/16
to Jenkins Developers
Hi Robert,

Thank you for your answer.

Can I find  example how to do it? Do you know if some plugin use this option?

Thanks,
Shurik
Reply all
Reply to author
Forward
0 new messages