Skip to content

Commit 8249f30

Browse files
Valentin Hoyetbgoglin
authored andcommitted
contrib/ci.inria.fr: use the "Pipeline: Step API" plugin to select unix nodes
Use nodesByLabel() to select nodes with the 'unix' label that are currently online. Don't do it manually since it required authorizing several sensitive procedures. Signed-off-by: Valentin Hoyet <[email protected]>
1 parent 74a5394 commit 8249f30

File tree

2 files changed

+2
-54
lines changed

2 files changed

+2
-54
lines changed

contrib/ci.inria.fr/Jenkinsfile-basic

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,12 @@
1111
// In "Additional Behaviours", enable "Checkout to specific local branch"
1212
// and leave "Branch name" empty.
1313
// Not needed for multi-branch pipelines which already BRANCH_NAME in the environment.
14-
import hudson.model.*
1514

1615
def gitBranch = ""
1716
def tarballgz
1817
def tarballbz2
1918
def statusHasChanged = false
2019

21-
def filterAvailableNode(nodeList) {
22-
def nodeToDelete = []
23-
nodeList.each { node ->
24-
echo "Searching for $node";
25-
if (node != null) {
26-
computer = Jenkins.instance.getNode(node).toComputer();
27-
if (computer.isOffline()) {
28-
echo "Error: $node is offline.";
29-
nodeToDelete.add(node);
30-
}
31-
}
32-
else {
33-
echo "Error: $node not found!";
34-
nodeToDelete.add(node);
35-
}
36-
}
37-
38-
return nodeList.findAll { !nodeToDelete.contains(it) }
39-
}
40-
4120
pipeline {
4221
agent none
4322

@@ -70,12 +49,7 @@ pipeline {
7049
script {
7150
listOfNodeNames = []
7251
if (env.NO_UNIX != 'true') {
73-
labelToSelect = 'unix'
74-
listOfNodeNames = jenkins.model.Jenkins.instance.nodes.collect {
75-
node -> node.getLabelString().contains(labelToSelect) ? node.name : null
76-
}
77-
listOfNodeNames.removeAll(Collections.singleton(null))
78-
listOfNodeNames = filterAvailableNode(listOfNodeNames)
52+
listOfNodeNames = nodesByLabel('unix')
7953
}
8054
if (env.NO_MSVC != 'true') {
8155
listOfNodeNames.push('VisualStudio')

contrib/ci.inria.fr/Jenkinsfile-extended

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,13 @@
1313
// In "Additional Behaviours", enable "Checkout to specific local branch"
1414
// and leave "Branch name" empty.
1515
// Not needed for multi-branch pipelines which already BRANCH_NAME in the environment.
16-
import hudson.model.*
1716

1817
def gitRepoURL = ""
1918
def gitBranch = ""
2019
def tarballgz
2120
def tarballbz2
2221
def statusHasChanged = false
2322

24-
def filterAvailableNode(nodeList) {
25-
def nodeToDelete = []
26-
nodeList.each { node ->
27-
echo "Searching for $node";
28-
if (node != null) {
29-
computer = Jenkins.instance.getNode(node).toComputer();
30-
if (computer.isOffline()) {
31-
echo "Error: $node is offline.";
32-
nodeToDelete.add(node);
33-
}
34-
}
35-
else {
36-
echo "Error: $node not found!";
37-
nodeToDelete.add(node);
38-
}
39-
}
40-
41-
return nodeList.findAll { !nodeToDelete.contains(it) }
42-
}
43-
4423
pipeline {
4524
agent none
4625

@@ -83,12 +62,7 @@ pipeline {
8362
script {
8463
listOfNodeNames = []
8564
if (env.NO_UNIX != 'true') {
86-
labelToSelect = 'unix'
87-
listOfNodeNames = jenkins.model.Jenkins.instance.nodes.collect {
88-
node -> node.getLabelString().contains(labelToSelect) ? node.name : null
89-
}
90-
listOfNodeNames.removeAll(Collections.singleton(null))
91-
listOfNodeNames = filterAvailableNode(listOfNodeNames)
65+
listOfNodeNames = nodesByLabel('unix')
9266
}
9367
if (env.NO_MINGW != 'true') {
9468
listOfNodeNames.push('MinGW')

0 commit comments

Comments
 (0)