How to get a list of jobs that are integrated with SonarQube

46 views
Skip to first unread message

Vijay Gongle

unread,
May 23, 2020, 9:43:09 PM5/23/20
to Jenkins Users
We have plenty of Jenkins job and most of them are running with SonarQube for analysis.

How to find out; how many such jobs are running with SonarQube ?

Thanks
Vijay

Jan Monterrubio

unread,
May 23, 2020, 11:09:19 PM5/23/20
to jenkins...@googlegroups.com
You could iterate over the list of jobs and get the configuration traits for them, and check if they have sonar cube, something like

Jenkins.getInstance().items.each { it -> 

it.configuration?.steps // not sure what XML type the sonar cube step is, if it has a step 
}


--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d82c76df-ce71-45c3-8449-79a1b1f19bac%40googlegroups.com.

Vijay Gongle

unread,
May 24, 2020, 12:12:46 PM5/24/20
to jenkins...@googlegroups.com
Thank you for responding. 
Can you help me completing the query; 

I would like to fetch the jobs which has the check mark "Prepare SonarQube Scanner environment" in Build Environment as shown below: 

image.png

Thanks, 
Vijay


Vijay Gongle

unread,
May 25, 2020, 4:58:31 PM5/25/20
to jenkins...@googlegroups.com

Jan Monterrubio

unread,
May 25, 2020, 5:29:19 PM5/25/20
to jenkins...@googlegroups.com
Can you post the config xml for one of the jobs? Hitting the config.xml should let us see what props there are. 

Vijay Gongle

unread,
May 25, 2020, 8:24:26 PM5/25/20
to jenkins...@googlegroups.com
Sure, below is the config.xml:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<maven2-moduleset plugin="maven-...@3.1.2">

<actions/>

<description> predev-ldap</description>

<keepDependencies>false</keepDependencies>

<properties>

<jenkins.plugins.maveninfo.config.MavenInfoJobConfig plugin="maven...@0.2.0">

<mainModulePattern/>

<dependenciesPattern/>

<assignName>false</assignName>

<nameTemplate/>

<assignDescription>false</assignDescription>

<descriptionTemplate/>

</jenkins.plugins.maveninfo.config.MavenInfoJobConfig>

<hudson.security.AuthorizationMatrixProperty>

<inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy"/>

<permission>

com.cloudbees.plugins.credentials.CredentialsProvider.Create:JB

</permission>

<permission>

com.cloudbees.plugins.credentials.CredentialsProvider.Delete:JB

</permission>

<permission>

com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains:JB

</permission>

<permission>

com.cloudbees.plugins.credentials.CredentialsProvider.Update:JB

</permission>

<permission>

com.cloudbees.plugins.credentials.CredentialsProvider.View:JB

</permission>

<permission>

com.synopsys.arc.jenkins.plugins.ownership.OwnershipPlugin.Jobs:JB

</permission>

<permission>hudson.model.Item.Build:JB</permission>

<permission>hudson.model.Item.Cancel:JB</permission>

<permission>hudson.model.Item.Configure:JB</permission>

<permission>hudson.model.Item.Delete:JB</permission>

<permission>hudson.model.Item.Discover:JB</permission>

<permission>hudson.model.Item.Move:JB</permission>

<permission>hudson.model.Item.Read:JB</permission>

<permission>hudson.model.Item.Release:JB</permission>

<permission>hudson.model.Item.Workspace:JB</permission>

<permission>hudson.model.Run.Delete:JB</permission>

<permission>hudson.model.Run.Replay:JB</permission>

<permission>hudson.model.Run.Update:JB</permission>

<permission>hudson.scm.SCM.Tag:JB</permission>

</hudson.security.AuthorizationMatrixProperty>

<com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab...@1.5.11">

<gitLabConnection>http://gitlab</gitLabConnection>

</com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>

<com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty plugin="owne...@0.12.1"/>

<org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty plugin="maven-repo-cleaner@1.2">

<notOnThisProject>false</notOnThisProject>

</org.jenkinsci.plugins.mavenrepocleaner.MavenRepoCleanerProperty>

<com.sonyericsson.rebuild.RebuildSettings plugin="reb...@1.29">

<autoRebuild>false</autoRebuild>

<rebuildDisabled>false</rebuildDisabled>

</com.sonyericsson.rebuild.RebuildSettings>

<hudson.model.ParametersDefinitionProperty>

<parameterDefinitions>

<net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition plugin="git-pa...@0.9.6">

<name>branch</name>

<description/>

<uuid>8c5b9fef-7649-48c1-77-8c78f9c02acd</uuid>

<type>PT_BRANCH_TAG</type>

<branch/>

<tagFilter>*</tagFilter>

<branchFilter>.*</branchFilter>

<sortMode>NONE</sortMode>

<defaultValue>sprint8-08212019</defaultValue>

<selectedValue>DEFAULT</selectedValue>

<quickFilterEnabled>false</quickFilterEnabled>

<listSize>5</listSize>

</net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition>

<hudson.model.ChoiceParameterDefinition>

<name>env</name>

<description/>

<choices class="java.util.Arrays$ArrayList">

<a class="string-array">

<string>predev</string>

</a>

</choices>

</hudson.model.ChoiceParameterDefinition>

<com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition plugin="extended-cho...@0.76">

<name>STACK_ID</name>

<description/>

<quoteValue>false</quoteValue>

<saveJSONParameterToFile>false</saveJSONParameterToFile>

<visibleItemCount>2</visibleItemCount>

<type>PT_SINGLE_SELECT</type>

<propertyFile>

file:///opt/portal2parameters/debug/stackidsuccess.properties

</propertyFile>

<propertyKey>STACK_ID</propertyKey>

<defaultPropertyFile>

file:///opt/portal2parameters/debug/stackidsuccess.properties

</defaultPropertyFile>

<defaultPropertyKey>STACK_ID</defaultPropertyKey>

<multiSelectDelimiter>,</multiSelectDelimiter>

<projectName>o-eportal2-debug-ldap</projectName>

</com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition>

</parameterDefinitions>

</hudson.model.ParametersDefinitionProperty>

</properties>

<scm class="hudson.plugins.git.GitSCM" plugin="g...@3.9.1">

<configVersion>2</configVersion>

<userRemoteConfigs>

<hudson.plugins.git.UserRemoteConfig>

<url>git:o-eportal2/o-eportal2-ldap.git</url>

</hudson.plugins.git.UserRemoteConfig>

</userRemoteConfigs>

<branches>

<hudson.plugins.git.BranchSpec>

<name>sprint8-05212020</name>

</hudson.plugins.git.BranchSpec>

</branches>

<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>

<submoduleCfg class="list"/>

<extensions/>

</scm>

<canRoam>true</canRoam>

<disabled>false</disabled>

<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>

<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>

<triggers>

<com.dabsquared.gitlabjenkins.GitLabPushTrigger plugin="gitlab...@1.5.11">

<spec/>

<triggerOnPush>true</triggerOnPush>

<triggerOnMergeRequest>true</triggerOnMergeRequest>

<triggerOnPipelineEvent>false</triggerOnPipelineEvent>

<triggerOnAcceptedMergeRequest>false</triggerOnAcceptedMergeRequest>

<triggerOnClosedMergeRequest>false</triggerOnClosedMergeRequest>

<triggerOnApprovedMergeRequest>true</triggerOnApprovedMergeRequest>

<triggerOpenMergeRequestOnPush>never</triggerOpenMergeRequestOnPush>

<triggerOnNoteRequest>true</triggerOnNoteRequest>

<noteRegex>Jenkins please retry a build</noteRegex>

<ciSkip>true</ciSkip>

<skipWorkInProgressMergeRequest>true</skipWorkInProgressMergeRequest>

<setBuildDescription>true</setBuildDescription>

<branchFilterType>NameBasedFilter</branchFilterType>

<includeBranchesSpec>sprint8-08212019</includeBranchesSpec>

<excludeBranchesSpec/>

<sourceBranchRegex/>

<targetBranchRegex/>

<secretToken>

{AQAAABAAAAAQF0chvThQyqKqkqh6OToxNzB3U0+0VE=}

</secretToken>

<pendingBuildName/>

<cancelPendingBuildsOnUpdate>false</cancelPendingBuildsOnUpdate>

</com.dabsquared.gitlabjenkins.GitLabPushTrigger>

</triggers>

<concurrentBuild>false</concurrentBuild>

<rootModule>

<groupId>com.o.eportal2.ldap</groupId>

<artifactId>o-eportal2-ldap</artifactId>

</rootModule>

<aggregatorStyleBuild>true</aggregatorStyleBuild>

<incrementalBuild>false</incrementalBuild>

<ignoreUpstremChanges>true</ignoreUpstremChanges>

<ignoreUnsuccessfulUpstreams>false</ignoreUnsuccessfulUpstreams>

<archivingDisabled>false</archivingDisabled>

<siteArchivingDisabled>false</siteArchivingDisabled>

<fingerprintingDisabled>false</fingerprintingDisabled>

<resolveDependencies>false</resolveDependencies>

<processPlugins>false</processPlugins>

<mavenValidationLevel>-1</mavenValidationLevel>

<runHeadless>false</runHeadless>

<disableTriggerDownstreamProjects>false</disableTriggerDownstreamProjects>

<blockTriggerWhenBuilding>true</blockTriggerWhenBuilding>

<settings class="jenkins.mvn.DefaultSettingsProvider"/>

<globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>

<reporters/>

<publishers>

<hudson.plugins.sonar.SonarPublisher plugin="sonar@2.9">

<branch/>

<mavenOpts/>

<jobAdditionalProperties/>

<settings class="jenkins.mvn.DefaultSettingsProvider"/>

<globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>

<usePrivateRepository>false</usePrivateRepository>

</hudson.plugins.sonar.SonarPublisher>

<hudson.plugins.emailext.ExtendedEmailPublisher plugin="emai...@2.63">

<recipientList>

</recipientList>

<configuredTriggers>

<hudson.plugins.emailext.plugins.trigger.AlwaysTrigger>

<email>

<subject>$PROJECT_DEFAULT_SUBJECT</subject>

<body>$PROJECT_DEFAULT_CONTENT</body>

<recipientProviders>

<hudson.plugins.emailext.plugins.recipients.ListRecipientProvider/>

</recipientProviders>

<attachmentsPattern/>

<attachBuildLog>false</attachBuildLog>

<compressBuildLog>false</compressBuildLog>

<replyTo>$PROJECT_DEFAULT_REPLYTO</replyTo>

<contentType>project</contentType>

</email>

</hudson.plugins.emailext.plugins.trigger.AlwaysTrigger>

</configuredTriggers>

<contentType>default</contentType>

<defaultSubject>$DEFAULT_SUBJECT</defaultSubject>

<defaultContent>

$DEFAULT_CONTENT ANALYSIS SUCCESSFUL, you can browse http://sonarqube/dashboard?id=com.o.eportal2.ldap%3Ao-eportal2-ldap

</defaultContent>

<attachmentsPattern/>

<presendScript>$DEFAULT_PRESEND_SCRIPT</presendScript>

<postsendScript>$DEFAULT_POSTSEND_SCRIPT</postsendScript>

<attachBuildLog>true</attachBuildLog>

<compressBuildLog>true</compressBuildLog>

<replyTo>

</replyTo>

<from/>

<saveOutput>false</saveOutput>

<disabled>false</disabled>

</hudson.plugins.emailext.ExtendedEmailPublisher>

</publishers>

<buildWrappers>

<hudson.plugins.sonar.SonarBuildWrapper plugin="sonar@2.9"/>

</buildWrappers>

<prebuilders/>

<postbuilders>

<hudson.tasks.Shell>

<command>

#!/bin/bash aws ecr create-repository --repository-name o-eportal-ldap 2>

</command>

</hudson.tasks.Shell>

</postbuilders>

<runPostStepsIfResult>

<name>FAILURE</name>

<ordinal>2</ordinal>

<color>RED</color>

<completeBuild>true</completeBuild>

</runPostStepsIfResult>

</maven2-moduleset>

 

Thanks


Vijay Gongle

unread,
May 26, 2020, 6:51:11 AM5/26/20
to jenkins...@googlegroups.com

Vijay


On May 25, 2020, at 8:23 PM, Vijay Gongle <vj.g...@gmail.com> wrote:


<image.png>


Thanks, 
Vijay

Dirk Heinrichs

unread,
May 26, 2020, 7:31:40 AM5/26/20
to jenkins...@googlegroups.com
Am Samstag, den 23.05.2020, 18:43 -0700 schrieb Vijay Gongle:

We have plenty of Jenkins job and most of them are running with SonarQube for analysis.

How to find out; how many such jobs are running with SonarQube ?

This is derived from a script I've used in the past to modify all Artifactory wrappers in all our jobs:

import hudson.model.*
import hudson.plugins.sonar.*
import jenkins.model.*

// Iterate over all jobs
Jenkins.instance.getAllItems(AbstractProject.class).each {job ->
  def fName = job.getFullName()

  // Iterate over all build wrappers
  for (wrapper in job.getBuildWrappersList()) {
  if (wrapper instanceof SonarBuildWrapper) {
  println(fName + ' has SonarQube configuration.')
  }
  }
}
println('Done.')

Paste it into the Script Console and see how it works. We don't use SonarCube ourselves, so it may work or not, but it should point you into the right direction.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
signature.asc

Jan Monterrubio

unread,
May 26, 2020, 9:58:44 AM5/26/20
to jenkins...@googlegroups.com
Thanks a lot Dirk, I was trying to write this on notepad without the scriptconsole (we also don't use sonar and i didn't have an instance available on my personal machine)

--
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-use...@googlegroups.com.

Vijay Gongle

unread,
May 26, 2020, 12:51:36 PM5/26/20
to jenkins...@googlegroups.com
Thank you Drik/Jan. 
I ran the above script and I get the below result with two of the job names which has SonarQube configurations. But I'm sure there are even more. 

Result

***** has SonarQube configuration.
***** has SonarQube configuration.
groovy.lang.MissingMethodException: No signature of method: hudson.maven.MavenModule.getBuildWrappersList() is applicable for argument types: () values: []
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at hudson.model.BuildableItemWithBuildWrappers$getBuildWrappersList.call(Unknown Source)
	at Script1$_run_closure1.doCall(Script1.groovy:10)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at groovy.lang.Closure.call(Closure.java:414)
	at groovy.lang.Closure.call(Closure.java:430)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066)
	at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at Script1.run(Script1.groovy:6)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:142)
	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:114)
	at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
	at hudson.util.RemotingDiagnostics.executeGroovy(RemotingDiagnostics.java:111)
	at jenkins.model.Jenkins._doScript(Jenkins.java:4381)
	at jenkins.model.Jenkins.doScript(Jenkins.java:4352)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
	at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:129)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:734)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:864)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:668)
	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
	at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:225)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at com.smartcodeltd.jenkinsci.plugin.assetbundler.filters.LessCSS.doFilter(LessCSS.java:47)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.audit_trail.AuditTrailFilter.doFilter(AuditTrailFilter.java:92)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter$1.call(ScmSyncConfigurationFilter.java:49)
	at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter$1.call(ScmSyncConfigurationFilter.java:44)
	at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationDataProvider.provideRequestDuring(ScmSyncConfigurationDataProvider.java:106)
	at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter.doFilter(ScmSyncConfigurationFilter.java:44)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at javax.servlet.FilterChain$doFilter$3.call(Unknown Source)
	at com.ceilfors.jenkins.plugins.jiratrigger.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.groovy:29)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:99)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:531)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
	at java.lang.Thread.run(Thread.java:748)


Jan Monterrubio

unread,
May 26, 2020, 1:05:12 PM5/26/20
to jenkins...@googlegroups.com
Looks like the script died after some job, can you print it’s name and check it’s config? Maybe we need to add a null check before we try to call getBuildWrapperList or the config type is doffeeent! 

Vijay Gongle

unread,
May 26, 2020, 1:45:06 PM5/26/20
to jenkins...@googlegroups.com
All the jobs has similar configurations for SonarQube as posted in the above config.xml 
It throws the below error: 

Thanks


Jan Monterrubio

unread,
May 26, 2020, 1:52:48 PM5/26/20
to jenkins...@googlegroups.com
	at Script1.run(Script1.groovy:6)

do you mind copy pasting your script here so we can check it out (with whatever modifications you have). 

Based on what Dirk said, you might have to tweak it:

"Paste it into the Script Console and see how it works. We don't use SonarCube ourselves, so it may work or not, but it should point you into the right direction."

Vijay Gongle

unread,
May 26, 2020, 1:57:02 PM5/26/20
to jenkins...@googlegroups.com
Ya sure, I haven't tweaked it honestly as I'm not aware of Groovy. So I have pasted the below script provided by Drik. 

import hudson.model.*
import hudson.plugins.sonar.*
import jenkins.model.*

// Iterate over all jobs
Jenkins.instance.getAllItems(AbstractProject.class).each {job ->
  def fName = job.getFullName()

  // Iterate over all build wrappers
  for (wrapper in job.getBuildWrappersList()) {
  if (wrapper instanceof SonarBuildWrapper) {
  println(fName + ' has SonarQube configuration.')
  }
  }
}
println('Done.')


Thanks

Jan Monterrubio

unread,
May 26, 2020, 2:17:32 PM5/26/20
to jenkins...@googlegroups.com
It seems that we do something like this to check if its gonna respond to that method:

if(project.respondsTo('getBuildWrappersList')) { // do other things here } MavenModuleSet doesn't have a buildWrappersList: https://javadoc.jenkins.io/plugin/maven-plugin/hudson/maven/MavenModule.html MavenModuleSet on the other hand, does: https://javadoc.jenkins.io/plugin/maven-plugin/hudson/maven/MavenModuleSet.html#getBuildWrappersList-- So you might have to check if the project responds to that method, and if so, check if it has sonar. If not, print out the job name and lets check if it has the same configuration object type: maven2-moduleset

Vijay Gongle

unread,
May 26, 2020, 11:06:14 PM5/26/20
to jenkins...@googlegroups.com
Thanks a lot Jan and Dirk. The below script worked for about 50%. Looking at the results, found that there are missing parts.  
import hudson.model.*
import hudson.plugins.sonar.*
import jenkins.model.*

// Iterate over all jobs
Jenkins.instance.getAllItems(AbstractProject.class).each {job ->
  def fName = job.getFullName()

  // Iterate over all build wrappers
  if(job.respondsTo('getBuildWrappersList')) {
  for (wrapper in job.getBuildWrappersList()) {
  if (wrapper instanceof SonarBuildWrapper) {
  println(fName + ' has SonarQube configuration.')
  }
  }
  }
  else{
    println(fName + ' has some issues.')
  }
}
println('Done.')

I don't see anything that has sonar quality gate. Do I have to run it separately or it can be combined in the above script?  
Below is the config xml. What needs to be replaced with, to get the results which has Sonar quality gates as well in the jobs? 

<org.quality.gates.jenkins.plugin.QGPublisher plugin="sonar-qua...@1.3.1">
<jobConfigData>
<projectKey>portal</projectKey>
<sonarInstanceName>Sonar</sonarInstanceName>
<buildStatus>FAILED</buildStatus>
</jobConfigData>
<buildDecision>
<qualityGatesProvider>
<qualityGateResponseParser/>
<sonarHttpRequester class="org.quality.gates.sonar.api61.SonarHttpRequester61">
<logged>false</logged>
</sonarHttpRequester>
<sonarInstanceValidationService/>
</qualityGatesProvider>
</buildDecision>
<jobConfigurationService/>
<jobExecutionService/>
</org.quality.gates.jenkins.plugin.QGPublisher>
<hudson.plugins.sonar.SonarPublisher plugin="sonar@2.9">
<branch/>
<mavenOpts/>
<jobAdditionalProperties/>
<settings class="jenkins.mvn.DefaultSettingsProvider"/>
<globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
<usePrivateRepository>false</usePrivateRepository>
</hudson.plugins.sonar.SonarPublisher>

Thanks, 

Jan Monterrubio

unread,
May 27, 2020, 12:14:29 AM5/27/20
to jenkins...@googlegroups.com
That looks like it would be in the set of Publishers?  https://javadoc.jenkins.io/plugin/maven-plugin/hudson/maven/MavenModuleSet.html#getPublishers--

So maybe try iterating through the publishers and if one of them is an instance of hudson.plugins.sonar.SonarPublisher , then you found another thing with sonar!

Jan Monterrubio

unread,
May 27, 2020, 12:15:05 AM5/27/20
to jenkins...@googlegroups.com
>   Do I have to run it separately or it can be combined in the above script?  

you can combine it:

if (buildWrappersList() { // the logic for the build wrappers }

if (publishersList() { // find sonar publisher }


Dirk Heinrichs

unread,
May 27, 2020, 1:53:24 AM5/27/20
to jenkins...@googlegroups.com
Am Dienstag, den 26.05.2020, 12:51 -0400 schrieb Vijay Gongle:

I ran the above script and I get the below result with two of the job names which has SonarQube configurations. But I'm sure there are even more. 

Result

***** has SonarQube configuration.
***** has SonarQube configuration.
groovy.lang.MissingMethodException: No signature of method: hudson.maven.MavenModule.getBuildWrappersList() is applicable for argument types: () values: []


Hmm, according to the module documentation (as posted by Jan), it should have that method. Maybe you just need to import the module. Try adding

import hudson.maven.MavenModuleSet.*

to the list of imports. We don't have any Maven jobs ourselves, so I never needed to care ;-)
signature.asc

Vijay Gongle

unread,
May 27, 2020, 4:28:47 PM5/27/20
to jenkins...@googlegroups.com
Hi Jan/Dirk, 
I used the below script and I'm getting all the plugins list that jobs are using but not the actual job name. Can you please help me how to tweak it. 

When I run the below script I get the results which shows " org.quality.gates.jenkins.plugin.QGPublisher@75f89c52" along with other such plugin details. But I would like to see which job is using this quality gate plugin. 

import hudson.model.*
import hudson.plugins.sonar.*
import jenkins.model.*

// Iterate over all jobs
Jenkins.instance.getAllItems(AbstractProject.class).each {job ->
  def fName = job.getFullName()

  // Iterate over all build wrappers
  if(job.respondsTo('getBuildWrappersList')) {
  for (wrapper in job.getBuildWrappersList()) {
  if (wrapper instanceof SonarBuildWrapper) {
  println(fName + ' has SonarQube configuration.')
  }
  }
  }
  //if(job.respondsTo('getPublishersList')) {
  for (wrapper in job.getPublishersList()) {
  //if (wrapper instanceof SonarPublisher) {
  println(wrapper)
  //}
  //}
  }
}
println('Done.')

Thanks, 
Vijay

Jan Monterrubio

unread,
May 27, 2020, 10:34:24 PM5/27/20
to jenkins...@googlegroups.com
Try printing like this:

println(“${job.getFullName()} has soñar configuration”)

It’s groovy interpolation. If that doesn’t work maybe just job.getName might do it. 

Dirk Heinrichs

unread,
May 28, 2020, 1:35:32 AM5/28/20
to jenkins...@googlegroups.com
Am Mittwoch, den 27.05.2020, 21:33 -0500 schrieb Jan Monterrubio:

Try printing like this:

println(“${job.getFullName()} has soñar configuration”)

The script already has a line for this.

Bye...
signature.asc

Vijay Gongle

unread,
May 28, 2020, 10:47:49 AM5/28/20
to jenkins...@googlegroups.com
Hi Jan/Dirk, 

Tweaking the script worked in charm. Below is the perfectly working script which gives me the results for any job that has sonarqube integrated or sonar quality gates integrated. 
It might help someone who is in similar boat. I thank a lot lot to you both for leading me in right direction which helped  in in achieving this. 

import hudson.model.*
import hudson.plugins.sonar.*
import jenkins.model.*

// Iterate over all jobs
Jenkins.instance.getAllItems(AbstractProject.class).each {job ->
  def fName = job.getFullName()

  // Iterate over all build wrappers
  if(job.respondsTo('getBuildWrappersList')) {
  for (wrapper in job.getBuildWrappersList()) {
  if (wrapper instanceof SonarBuildWrapper) {
  println(fName + ' has SonarQube configuration.')
  }
  }
  }
  if(job.respondsTo('getPublishersList')) {
  for (String str : job.getPublishersList()) {
    //def str = wrapper
    if(str.contains("org.quality.gates.jenkins.plugin.QGPublisher")){
  println(fName + ' has Quality Gate plugin')
  }
  }
  }
}
println('Done.')

Thanks, 
Vijay

--
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-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages