I created 2 groovy scripts that I execute in a jenkins instance to figure 
out the list to be used and to be configured within the `build.gradle` file

Jenkins.instance.pluginManager.plugins
.findAll { !(it.shortName in ['job-dsl', 'structs']) }
.collect { "testPlugins 
'${it.manifest.mainAttributes.getValue("Group-Id")}:${it.shortName}:${it.version}'"
 
}
.sort()
.each { println it }

and testCompile dependencies
Jenkins.instance.pluginManager.plugins
.findAll { !(it.shortName in ['job-dsl', 'structs']) }
.collect { "testCompile 
'${it.manifest.mainAttributes.getValue("Group-Id")}:${it.shortName}:${it.version}@jar'"
 
}
.sort()
.each { println it }

On Wednesday, December 16, 2020 at 6:48:41 PM UTC+1 Charles Moulliard wrote:

> Hi
>
> As a java unit test will need jar files, it is then needed to load them nd 
> to declare them within the pom.xml file or build.gradle file
>
> Example: 
>     
> testCompile("org.jenkins-ci.main:jenkins-test-harness:${jenkinsTestHarness}")
>     testCompile("org.jenkins-ci.main:jenkins-war:${jenkinsCore}")
>     
> testCompile("org.jenkins-ci.plugins:script-security:${jenkinsTestSecurityScript}@jar")
>
>     // Add the jar file as the testPlugins will install the hpi/jpi files 
> and not the jar needed by the junit test
>     testCompile 'org.jenkins-ci.tools:git-parameter:0.9.13@jar'
>
>     testCompile 'org.jenkins-ci.plugins:structs:1.20@jar'
>     testCompile 'org.jenkins-ci.plugins:git:3.10.0@jar'
>     testCompile 'org.jenkins-ci.plugins:git-client:3.5.1@jar'
>     testCompile 'org.jenkins-ci.plugins:credentials:2.3.9@jar'
>     testCompile 'org.jenkins-ci.plugins:scm-api:2.6.4@jar'
>     testCompile 'org.jenkins-ci.plugins:matrix-project:1.18@jar'
>     testCompile 
> 'org.jenkins-ci.plugins:global-variable-string-parameter:1.2@jar'
>     testCompile 'org.jenkins-ci.plugins:junit:1.47@jar'
>
>     testCompile 'org.jenkins-ci.plugins:workflow-remote-loader:1.5@jar'
>     testCompile 
> 'org.jenkins-ci.plugins.workflow:workflow-aggregator:2.6@jar'
>     testCompile 'org.jenkins-ci.plugins.workflow:workflow-api:2.40@jar'
>     testCompile 
> 'org.jenkins-ci.plugins.workflow:workflow-basic-steps:2.18@jar'
>     testCompile 
> 'org.jenkins-ci.plugins.workflow:workflow-scm-step:2.11@jar'
>     testCompile 'org.jenkins-ci.plugins.workflow:workflow-cps:2.80@jar'
>     testCompile 
> 'org.jenkins-ci.plugins.workflow:workflow-durable-task-step:2.35@jar'
>     testCompile 'org.jenkins-ci.plugins.workflow:workflow-job:2.38@jar'
>     testCompile 
> 'org.jenkins-ci.plugins.workflow:workflow-multibranch:2.20@jar'
>     testCompile 
> 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.23@jar'
>     testCompile 'org.jenkins-ci.plugins.workflow:workflow-support:3.3@jar'
>
>     testCompile 'org.jenkins-ci.plugins:matrix-auth:2.6.2@jar'
>
>     testCompile 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r'
>     
>     // Plugins to install in test jenkins instance running locally
>     testPlugins 'org.jenkins-ci.main:maven-plugin:3.8'
>
>     testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:5.14'
>     testPlugins 'org.jenkins-ci.plugins:credentials:2.3.9'
>     testPlugins 'org.jenkins-ci.plugins:structs:1.20'
>     testPlugins 
> 'org.jenkins-ci.plugins:global-variable-string-parameter:1.2'
>
>     testPlugins 'org.jenkins-ci.tools:git-parameter:0.9.13'
>     testPlugins 'org.jenkins-ci.plugins:git:3.10.0'
>     testPlugins 'org.jenkins-ci.plugins:git-client:3.5.1'
>     testPlugins 'org.jenkins-ci.plugins:scm-api:2.6.4'
>     testPlugins 'org.jenkins-ci.plugins:matrix-project:1.18'
>
>     testPlugins 'org.jenkins-ci.plugins:workflow-remote-loader:1.5'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-aggregator:2.6'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-api:2.40'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-basic-steps:2.18'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-scm-step:2.11'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2.80'
>     testPlugins 
> 'org.jenkins-ci.plugins.workflow:workflow-durable-task-step:2.35'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:2.38'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-multibranch:2.20'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.23'
>     testPlugins 'org.jenkins-ci.plugins.workflow:workflow-support:3.3'
>
>     testPlugins 'org.jenkins-ci.plugins:matrix-auth:2.6.2'
>
>     testPlugins 'org.jenkins-ci.plugins:junit:1.47'
>
>     testPlugins 'org.jenkins-ci.plugins:matrix-project:1.18'
>
> As you can imagine, this process is long,tedious, will change when we 
> upgrade to another jenkins server (as the list of the default plugins will 
> be updated).
>
> Question:
> Is there a script, tool able to grab from jenkins the plugins list and 
> next to create the corresponding plugins to be imported for Jenkinsrule 
> unit test and GAVs dependencies (pom.xml or build.gradle) ?
>
> Cheers
>
> charles
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/37fb12c3-604e-4ad5-881a-4836e1a7dca3n%40googlegroups.com.

Reply via email to