Skip to content

Commit a149794

Browse files
committed
Fix groovy code format with linters
Signed-off-by: Sunnatillo <[email protected]>
1 parent 7ecfef0 commit a149794

10 files changed

+779
-792
lines changed

.groovylintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "recommended",
3+
"rules": {
4+
"CompileStatic": { "enabled": false },
5+
"LineLength": { "enabled": false },
6+
"DuplicateMapLiteral": { "enabled": false },
7+
"DuplicateStringLiteral": { "enabled": false },
8+
"DuplicateNumberLiteral": { "enabled": false }
9+
}
10+
}
Lines changed: 97 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,117 @@
1-
import java.text.SimpleDateFormat
2-
31
// 3 hours
4-
def TIMEOUT = 10800
2+
int timeout = 10800
53

64
script {
5+
UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git"
6+
echo "Test triggered from ${UPDATED_REPO}"
7+
ci_git_url = 'https://github.com/metal3-io/project-infra.git'
78

8-
UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git"
9-
echo "Test triggered from ${UPDATED_REPO}"
10-
ci_git_url = "https://github.com/metal3-io/project-infra.git"
11-
12-
if ("${env.REPO_OWNER}" == 'metal3-io' && "${env.REPO_NAME}" == 'project-infra') {
13-
ci_git_branch = (env.PULL_PULL_SHA) ?: 'main'
14-
ci_git_base = (env.PULL_BASE_REF) ?: 'main'
15-
// Fetch the base branch and the ci_git_branch when running on project-infra PR
16-
refspec = '+refs/heads/' + ci_git_base + ':refs/remotes/origin/' + ci_git_base + ' ' + ci_git_branch
9+
if ("${env.REPO_OWNER}" == 'metal3-io' && "${env.REPO_NAME}" == 'project-infra') {
10+
ci_git_branch = (env.PULL_PULL_SHA) ?: 'main'
11+
ci_git_base = (env.PULL_BASE_REF) ?: 'main'
12+
// Fetch the base branch and the ci_git_branch when running on project-infra PR
13+
refspec = '+refs/heads/' + ci_git_base + ':refs/remotes/origin/' + ci_git_base + ' ' + ci_git_branch
1714
} else {
18-
ci_git_branch = 'main'
19-
refspec = '+refs/heads/*:refs/remotes/origin/*'
20-
}
15+
ci_git_branch = 'main'
16+
refspec = '+refs/heads/*:refs/remotes/origin/*'
17+
}
2118
echo "Checkout ${ci_git_url} branch ${ci_git_branch}"
2219
}
2320

2421
pipeline {
2522
/* In the BML we always run on the same machine so concurrency must be disabled */
26-
options {
27-
disableConcurrentBuilds()
28-
}
29-
agent { label 'metal3ci-bml-jenkins-worker' }
30-
environment {
31-
METAL3_CI_USER="metal3ci"
32-
REPO_ORG = "${env.REPO_OWNER}"
33-
REPO_NAME = "${env.REPO_NAME}"
34-
UPDATED_REPO = "${UPDATED_REPO}"
35-
REPO_BRANCH = "${env.PULL_BASE_REF}"
36-
UPDATED_BRANCH = "${env.PULL_PULL_SHA}"
37-
BUILD_TAG = "${env.BUILD_TAG}"
38-
PR_ID = "${env.PULL_NUMBER}"
39-
IMAGE_OS = "${IMAGE_OS}"
40-
CAPM3RELEASEBRANCH = "${capm3_release_branch}"
41-
BMORELEASEBRANCH = "${bmo_release_branch}"
42-
NUM_NODES = "${NUM_NODES}"
43-
WORKER_MACHINE_COUNT = 1
44-
CONTROL_PLANE_MACHINE_COUNT = 1
45-
CAPI_VERSION = "${CAPI_VERSION}"
46-
CAPM3_VERSION = "${CAPM3_VERSION}"
47-
BOOTSTRAP_CLUSTER = "minikube"
48-
EXTERNAL_VLAN_ID = "3"
49-
}
50-
stages {
51-
stage('SCM') {
52-
options {
53-
timeout(time: 5, unit: 'MINUTES')
54-
}
55-
steps {
56-
/* Checkout CI Repo */
57-
checkout([
58-
$class: 'GitSCM',
59-
branches: [
60-
[name: ci_git_branch]
61-
],
62-
doGenerateSubmoduleConfigurations: false,
63-
extensions: [
64-
[$class: 'WipeWorkspace'],
65-
[$class: 'CleanCheckout'],
66-
[$class: 'CleanBeforeCheckout']
67-
],
68-
submoduleCfg: [],
69-
userRemoteConfigs: [[url: ci_git_url, refspec: refspec]]
70-
])
71-
script {
72-
CURRENT_START_TIME = System.currentTimeMillis()
73-
}
74-
}
23+
options {
24+
disableConcurrentBuilds()
7525
}
76-
stage('Run integration test') {
77-
options {
78-
timeout(time: TIMEOUT, unit: 'SECONDS')
79-
}
80-
steps {
81-
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]) {
82-
withCredentials([usernamePassword(credentialsId: 'metal3-bml-ilo-credentials', usernameVariable: 'BML_ILO_USERNAME', passwordVariable: 'BML_ILO_PASSWORD')]) {
83-
withCredentials([string(credentialsId: 'metal3-clusterctl-github-token', variable: 'GITHUB_TOKEN')]){
84-
timestamps {
85-
sh "./jenkins/scripts/bare_metal_lab/bml_integration_test.sh"
86-
}
26+
agent { label 'metal3ci-bml-jenkins-worker' }
27+
environment {
28+
METAL3_CI_USER = 'metal3ci'
29+
REPO_ORG = "${env.REPO_OWNER}"
30+
REPO_NAME = "${env.REPO_NAME}"
31+
UPDATED_REPO = "${UPDATED_REPO}"
32+
REPO_BRANCH = "${env.PULL_BASE_REF}"
33+
UPDATED_BRANCH = "${env.PULL_PULL_SHA}"
34+
BUILD_TAG = "${env.BUILD_TAG}"
35+
PR_ID = "${env.PULL_NUMBER}"
36+
IMAGE_OS = "${IMAGE_OS}"
37+
CAPM3RELEASEBRANCH = "${capm3_release_branch}"
38+
BMORELEASEBRANCH = "${bmo_release_branch}"
39+
NUM_NODES = "${NUM_NODES}"
40+
WORKER_MACHINE_COUNT = 1
41+
CONTROL_PLANE_MACHINE_COUNT = 1
42+
CAPI_VERSION = "${CAPI_VERSION}"
43+
CAPM3_VERSION = "${CAPM3_VERSION}"
44+
EPHEMERAL_CLUSTER = 'minikube'
45+
EXTERNAL_VLAN_ID = '3'
46+
}
47+
stages {
48+
stage('SCM') { ;
49+
options {
50+
timeout(time: 5, unit: 'MINUTES')
51+
}
52+
steps {
53+
/* Checkout CI Repo */
54+
checkout([
55+
$class: 'GitSCM',
56+
branches: [
57+
[name: ci_git_branch]
58+
],
59+
doGenerateSubmoduleConfigurations: false,
60+
extensions: [
61+
[$class: 'WipeWorkspace'],
62+
[$class: 'CleanCheckout'],
63+
[$class: 'CleanBeforeCheckout']
64+
],
65+
submoduleCfg: [],
66+
userRemoteConfigs: [[url: ci_git_url, refspec: refspec]]
67+
])
68+
script {
69+
CURRENT_START_TIME = System.currentTimeMillis()
70+
}
8771
}
88-
}
8972
}
90-
}
91-
}
92-
}
93-
post {
94-
always {
95-
script {
96-
CURRENT_END_TIME = System.currentTimeMillis()
97-
if ((((CURRENT_END_TIME - CURRENT_START_TIME)/1000) - TIMEOUT) > 0) {
98-
echo "Failed due to timeout"
99-
currentBuild.result = 'FAILURE'
73+
stage('Run integration test') {
74+
options {
75+
timeout(time: timeout, unit: 'SECONDS')
76+
}
77+
steps {
78+
withCredentials([
79+
sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY'),
80+
usernamePassword(credentialsId: 'metal3-bml-ilo-credentials', usernameVariable: 'BML_ILO_USERNAME', passwordVariable: 'BML_ILO_PASSWORD'),
81+
string(credentialsId: 'metal3-clusterctl-github-token', variable: 'GITHUB_TOKEN')]) {
82+
timestamps {
83+
sh './jenkins/scripts/bare_metal_lab/bml_integration_test.sh'
84+
}
85+
}
86+
}
10087
}
101-
}
102-
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]){
103-
withCredentials([usernamePassword(credentialsId: 'metal3-bml-ilo-credentials', usernameVariable: 'BML_ILO_USERNAME', passwordVariable: 'BML_ILO_PASSWORD')]) {
104-
timestamps {
105-
sh "./jenkins/scripts/dynamic_worker_workflow/fetch_logs.sh"
88+
}
89+
post {
90+
always {
91+
script {
92+
CURRENT_END_TIME = System.currentTimeMillis()
93+
if ((((CURRENT_END_TIME - CURRENT_START_TIME) / 1000) - timeout) > 0) {
94+
echo 'Failed due to timeout'
95+
currentBuild.result = 'FAILURE'
96+
}
97+
}
98+
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY'),
99+
usernamePassword(credentialsId: 'metal3-bml-ilo-credentials', usernameVariable: 'BML_ILO_USERNAME', passwordVariable: 'BML_ILO_PASSWORD')]) {
100+
timestamps {
101+
sh './jenkins/scripts/dynamic_worker_workflow/fetch_logs.sh'
102+
archiveArtifacts "logs-${env.BUILD_TAG}.tgz"
103+
}
104+
}
106105
archiveArtifacts "logs-${env.BUILD_TAG}.tgz"
107-
}
108106
}
109-
}
110-
archiveArtifacts "logs-${env.BUILD_TAG}.tgz"
111-
}
112-
success {
113-
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY')]){
114-
withCredentials([usernamePassword(credentialsId: 'metal3-bml-ilo-credentials', usernameVariable: 'BML_ILO_USERNAME', passwordVariable: 'BML_ILO_PASSWORD')]) {
115-
withCredentials([string(credentialsId: 'metal3-clusterctl-github-token', variable: 'GITHUB_TOKEN')]){
116-
timestamps {
117-
sh "./jenkins/scripts/bare_metal_lab/bml_cleanup.sh"
107+
success {
108+
withCredentials([sshUserPrivateKey(credentialsId: 'metal3ci_city_cloud_ssh_keypair', keyFileVariable: 'METAL3_CI_USER_KEY'),
109+
usernamePassword(credentialsId: 'metal3-bml-ilo-credentials', usernameVariable: 'BML_ILO_USERNAME', passwordVariable: 'BML_ILO_PASSWORD'),
110+
string(credentialsId: 'metal3-clusterctl-github-token', variable: 'GITHUB_TOKEN')]) {
111+
timestamps {
112+
sh './jenkins/scripts/bare_metal_lab/bml_cleanup.sh'
113+
}
118114
}
119-
}
120115
}
121-
}
122116
}
123-
}
124117
}
Lines changed: 72 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,87 @@
1-
import java.text.SimpleDateFormat
2-
31
// 3 hour
4-
def TIMEOUT = 10800
2+
int timeout = 10800
53

64
// Set defaults for non-PR jobs
7-
def pullSha = (env.PULL_PULL_SHA) ?: "main"
8-
def pullBase = (env.PULL_BASE_REF) ?: "main"
9-
def repoUrl = "https://github.com/metal3-io/baremetal-operator.git"
5+
string pullSha = (env.PULL_PULL_SHA) ?: 'main'
6+
string pullBase = (env.PULL_BASE_REF) ?: 'main'
7+
string repoUrl = 'https://github.com/metal3-io/baremetal-operator.git'
108
// Fetch the base branch and the pullSha, nothing else
11-
def refspec = '+refs/heads/' + pullBase + ':refs/remotes/origin/' + pullBase + ' ' + pullSha
9+
string refspec = '+refs/heads/' + pullBase + ':refs/remotes/origin/' + pullBase + ' ' + pullSha
1210

1311
pipeline {
14-
environment {
15-
GINKGO_FOCUS="${GINKGO_FOCUS}"
16-
}
17-
agent none
18-
stages {
19-
stage("Run Baremetal Operator optional e2e tests") {
20-
matrix {
21-
agent { label "metal3ci-8c16gb-ubuntu" }
22-
// Skip redfish on PRs, test all for periodic jobs
23-
when {
24-
anyOf {
25-
expression { env.BMC_PROTOCOL != "redfish" }
26-
triggeredBy 'TimerTrigger'
27-
}
28-
}
29-
axes {
30-
axis {
31-
name 'BMC_PROTOCOL'
32-
values 'ipmi', 'redfish', 'redfish-virtualmedia'
33-
}
34-
}
35-
environment {
36-
BMC_PROTOCOL = "${BMC_PROTOCOL}"
37-
}
38-
stages {
39-
stage("Checkout source code") {
40-
steps {
41-
checkout scmGit(
12+
environment {
13+
GINKGO_FOCUS = "${GINKGO_FOCUS}"
14+
}
15+
agent none
16+
stages {
17+
stage('Run Baremetal Operator optional e2e tests') {
18+
matrix {
19+
agent { label 'metal3ci-8c16gb-ubuntu' }
20+
// Skip redfish on PRs, test all for periodic jobs
21+
when {
22+
anyOf {
23+
expression { env.BMC_PROTOCOL != 'redfish' }
24+
triggeredBy 'TimerTrigger'
25+
}
26+
}
27+
axes {
28+
axis {
29+
name 'BMC_PROTOCOL'
30+
values 'ipmi', 'redfish', 'redfish-virtualmedia'
31+
}
32+
}
33+
environment {
34+
BMC_PROTOCOL = "${BMC_PROTOCOL}"
35+
}
36+
stages {
37+
stage('Checkout source code') {
38+
steps {
39+
checkout scmGit(
4240
branches: [[name: pullSha]],
4341
userRemoteConfigs: [[url: repoUrl, refspec: refspec]],
44-
extensions: [[$class: "WipeWorkspace"],
45-
[$class: "CleanCheckout"],
46-
[$class: "CleanBeforeCheckout"],
47-
[$class: "PreBuildMerge", options: [mergeTarget: pullBase, mergeRemote: "origin"]],
48-
[$class: "UserIdentity", name: "Test", email: "[email protected]"],
42+
extensions: [[$class: 'WipeWorkspace'],
43+
[$class: 'CleanCheckout'],
44+
[$class: 'CleanBeforeCheckout'],
45+
[$class: 'PreBuildMerge', options: [mergeTarget: pullBase, mergeRemote: 'origin']],
46+
[$class: 'UserIdentity', name: 'Test', email: '[email protected]'],
4947
cloneOption(honorRefspec: true)],
5048
submoduleCfg: [],)
51-
script {
52-
CURRENT_START_TIME = System.currentTimeMillis()
53-
}
54-
}
55-
}
56-
stage("Run Baremetal Operator optional e2e tests") {
57-
options {
58-
timeout(time: TIMEOUT, unit: "SECONDS")
59-
ansiColor("xterm")
60-
}
61-
steps {
62-
withCredentials([string(credentialsId: "metal3-clusterctl-github-token", variable: "GITHUB_TOKEN")]) {
63-
timestamps {
64-
sh "./hack/ci-e2e.sh"
65-
}
66-
}
67-
}
68-
post {
69-
always {
70-
script {
71-
CURRENT_END_TIME = System.currentTimeMillis()
72-
if ((((CURRENT_END_TIME - CURRENT_START_TIME)/1000) - TIMEOUT) > 0) {
73-
echo "Failed due to timeout"
74-
currentBuild.result = "FAILURE"
75-
}
76-
}
77-
archiveArtifacts "artifacts*.tar.gz"
78-
timestamps {
79-
/* Clean up */
80-
sh "make clean-e2e"
49+
script {
50+
CURRENT_START_TIME = System.currentTimeMillis()
51+
}
52+
}
53+
}
54+
stage('Run Baremetal Operator optional e2e tests') {
55+
options {
56+
timeout(time: timeout, unit: 'SECONDS')
57+
ansiColor('xterm')
58+
}
59+
steps {
60+
withCredentials([string(credentialsId: 'metal3-clusterctl-github-token', variable: 'GITHUB_TOKEN')]) {
61+
timestamps {
62+
sh './hack/ci-e2e.sh'
63+
}
64+
}
65+
}
66+
post {
67+
always {
68+
script {
69+
CURRENT_END_TIME = System.currentTimeMillis()
70+
if ((((CURRENT_END_TIME - CURRENT_START_TIME) / 1000) - timeout) > 0) {
71+
echo 'Failed due to timeout'
72+
currentBuild.result = 'FAILURE'
73+
}
74+
}
75+
archiveArtifacts 'artifacts*.tar.gz'
76+
timestamps {
77+
/* Clean up */
78+
sh 'make clean-e2e'
79+
}
80+
}
81+
}
82+
}
8183
}
82-
}
8384
}
84-
}
8585
}
86-
}
8786
}
88-
}
8987
}

0 commit comments

Comments
 (0)