Use get() instead of the deprecated getInstance() to access to the jenkins singleton.

This commit is contained in:
Manuele Simi 2020-03-11 16:01:06 -04:00
parent eeec309fd7
commit 3b70bfc602
2 changed files with 6 additions and 3 deletions

4
Jenkinsfile vendored
View File

@ -21,7 +21,7 @@ pipeline {
stage('walking projects') {
steps {
script {
Jenkins.getInstance().getAllItems(TopLevelItem.class).each { p ->
Jenkins.get().getAllItems(TopLevelItem.class).each { p ->
projects2artifacts[p.name] = []
p.getAllJobs().each { j -> projects2artifacts[p.name] << j.name; artifacts2projects[j.name] = p.name }
}
@ -35,7 +35,7 @@ pipeline {
steps {
script {
// get all the maven modules and their dependencies
Jenkins.getInstance().getAllItems(hudson.maven.MavenModule.class).each { m ->
Jenkins.get().getAllItems(hudson.maven.MavenModule.class).each { m ->
modules2deps[m.name] = []
m.getDependencies().each { d -> modules2deps[m.name] << "${d.groupId}:${d.artifactId}" }
}

View File

@ -11,4 +11,7 @@ Given a Jenkins project P:
* [Pipeline: Maven](https://plugins.jenkins.io/pipeline-maven)
* [Pipeline: Basic Steps](https://plugins.jenkins.io/workflow-basic-steps)
* [Pipeline: Dependency Walker](https://plugins.jenkins.io/pipeline-dependency-walker/)
* [NodeLabelParameter](https://plugins.jenkins.io/nodelabelparameter) (to allow to dynamically select the node on which a job should be executed)
## Documentation
* [jenkins.model.Jenkins](https://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html)
* [jenkins.model.ItemGroup](https://javadoc.jenkins-ci.org/hudson/model/ItemGroup.html)