forked from tiiuae/ghaf-jenkins-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fmo-os-main-pipeline.groovy
107 lines (94 loc) · 2.7 KB
/
fmo-os-main-pipeline.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env groovy
// SPDX-FileCopyrightText: 2024 Technology Innovation Institute (TII)
//
// SPDX-License-Identifier: Apache-2.0
///////////////////////////////////////////////////////////////////////
// Default values for parameters
DEFAULT_URL = 'https://github.com/tiiuae/FMO-OS.git'
DEFAULT_REF = 'main'
// Utils module
def utils = null
// Parallel stages for targets under test
def tests = [:]
// FMO-OS targets
def targets = [
'.#packages.x86_64-linux.fmo-os-installer-public-debug',
'.#packages.x86_64-linux.fmo-os-installer-public-release',
'.#packages.x86_64-linux.fmo-os-rugged-laptop-7330-public-debug',
'.#packages.x86_64-linux.fmo-os-rugged-laptop-7330-public-release',
'.#packages.x86_64-linux.fmo-os-rugged-tablet-7230-public-debug',
'.#packages.x86_64-linux.fmo-os-rugged-tablet-7230-public-release'
]
///////////////////////////////////////////////////////////////////////
// define code blocks per target to execute as brances for parallel step
targets.each {
def target = "${it}"
tests[target] = {
stage("${target}") {
node('built-in') {
stage("Build ${target}") {
dir(FMO_PATH) {
utils.nix_build("${target}", 'archive')
}
}
}
}
}
}
///////////////////////////////////////////////////////////////////////
pipeline {
agent none
parameters {
string description: 'Repository URL',
name: 'URL',
defaultValue: DEFAULT_URL
string description: 'Branch (or revision reference) Specifier',
name: 'BRANCH',
defaultValue: DEFAULT_REF
}
triggers {
pollSCM '* * * * *'
}
options {
disableConcurrentBuilds()
buildDiscarder logRotator(
artifactDaysToKeepStr: '7',
artifactNumToKeepStr: '10',
daysToKeepStr: '70',
numToKeepStr: '100'
)
}
environment {
FMO_PATH = "$JENKINS_HOME/workspace/FMO-OS-main-ws"
// Use default values if parameter values are not yet defined
// like the case on the very first run
FMO_URL = params.getOrDefault('URL', DEFAULT_URL)
FMO_REF = params.getOrDefault('BRANCH', DEFAULT_REF)
}
stages {
stage('Checkout') {
agent any
steps {
script {
utils = load "utils.groovy"
dir(FMO_PATH) {
def scm = checkout scmGit(
branches: [[name: FMO_REF]],
extensions: [cleanBeforeCheckout()],
userRemoteConfigs: [[url: FMO_URL]]
)
env.TARGET_COMMIT = scm.GIT_COMMIT
env.ARTIFACTS_REMOTE_PATH = "${JOB_NAME}/build_${BUILD_ID}-commit_${TARGET_COMMIT}"
}
}
}
}
stage('Test targets') {
steps {
script {
parallel tests
}
}
}
}
}