Thanks Ewelina,

Actually we are looking for a method to retrieve the class instance which 
is keeping the BlackDuckHub configuration on master level.

 

For example for SonarQube it will be

 

import jenkins.model.Jenkins;

import hudson.plugins.sonar.SonarGlobalConfiguration;

import hudson.plugins.sonar.SonarInstallation;

 

def sonarDescr = 
jenkins.getInstance().getDescriptorByType(SonarGlobalConfiguration)l

sonarDescr.setInstallations(

new SonarInstallation(

'sonar',

'http://sonarqube.com',

// Other constructor properties...

)

);

sonarDescr.save();


Didn't find it in this class.

On Monday, March 26, 2018 at 10:54:17 PM UTC+5:30, Ewelina Wilkosz wrote:
>
> I haven't tried that and don't know the plugin, but I think you need to 
> find descriptor first
> since I've found global.jelly for DetectPostBuildStep (
> https://github.com/jenkinsci/blackduck-detect-plugin/blob/master/src/main/resources/com/blackducksoftware/integration/detect/jenkins/post/DetectPostBuildStep/global.jelly)
>  
> I would risk and say it may be that one: 
>
> https://github.com/blackducksoftware/blackduck-detect-plugin/blob/9993e4a22bf375c11d1872e4d619b83940b7e777/src/main/java/com/blackducksoftware/integration/detect/jenkins/post/DetectPostBuildStepDescriptor.java
>
> you can see there are public setters in it, so getDescriptor for 
> com.blackducksoftware.integration.detect.jenkins.post 
> (I guess) and use it to call setters
> does it make sense to you?
>
> In the future, hopefully, Jenkins Configuration as Code Plugin will be 
> able to take care of that for you :)
>
> On Monday, March 26, 2018 at 5:50:54 PM UTC+2, Sabyasachi Das wrote:
>>
>> Hi All,
>>
>> I have installed Blackduck detect plugin in jenkins. I want to do 
>> Blackduck  detect configurations via groovy script.
>>
>> I am able to do using GUI Manage Jenkins -> configure system but need to 
>> do similar activity via groovy script.
>> Similar configurations for other plugins can be done for example below. 
>> But for BlackDuck detect I cant find any appropriate class to provide.
>> https://github.com/blackducksoftware/blackduck-detect-plugin
>>
>> Anyone please help me on this.
>>
>> Thanks,
>> Sabya
>>
>> Sonar Script
>> ==========================
>> import jenkins.model.*
>> import hudson.plugins.sonar.*
>> import hudson.plugins.sonar.model.*
>> import jenkins.plugins.slack.SlackNotifier
>> import jenkins.plugins.git.GitSCMSource
>>
>> def inst = Jenkins.getInstance()
>>
>> def desc = inst.getDescriptor("hudson.plugins.sonar.SonarPublisher")
>> //or slack or git
>> def slack = instance.getDescriptor(SlackNotifier)
>> def gitPluginSetup = instance.getDescriptor(GitSCM)
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/06a99280-0b86-4d09-b0b9-4e4b5262da78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to