Skip to content

Commit

Permalink
Add setup stage to only load project configuration
Browse files Browse the repository at this point in the history
RUN_TYPE choice parameter added with 'normal' and 'setup' runs.
Only 'Setup' stage is executed when 'setup' is chosen.
'Setup' stage only loads confifuration and marks result as NOT_BUILT.
'Setup' stage is also run when 'queue' method (from Job DSL plugin)
is called with JCasC.

Signed-off-by: Marko Kaapu <[email protected]>
  • Loading branch information
mkaapu committed Dec 9, 2024
1 parent 0246bcb commit 0fe53ec
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 0 deletions.
41 changes: 41 additions & 0 deletions fmo-os-main-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def targets = [
'.#packages.x86_64-linux.fmo-os-rugged-tablet-7230-public-release'
]

// RUN_TYPE parameter description
def run_type_description = '''
normal - executing all configured build and test stages normally<br>
setup - only reloading configuration, not running futher stages
'''

///////////////////////////////////////////////////////////////////////

// define code blocks per target to execute as brances for parallel step
Expand Down Expand Up @@ -57,6 +63,9 @@ pipeline {
string description: 'Branch (or revision reference) Specifier',
name: 'BRANCH',
defaultValue: DEFAULT_REF
choice name: 'RUN_TYPE',
choices: ['normal', 'setup' ],
description: run_type_description
}
triggers {
pollSCM '* * * * *'
Expand All @@ -79,8 +88,32 @@ pipeline {
FMO_REF = params.getOrDefault('BRANCH', DEFAULT_REF)
}
stages {
stage('Setup') {
when {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
steps {
script {
String note = 'Project configuration parsed.'
echo note
currentBuild.description = note
currentBuild.result = 'NOT_BUILT'
}
}
}
stage('Checkout') {
agent any
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
utils = load "utils.groovy"
Expand All @@ -97,6 +130,14 @@ pipeline {
}
}
stage('Test targets') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
parallel tests
Expand Down
52 changes: 52 additions & 0 deletions ghaf-main-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ properties([
githubProjectProperty(displayName: '', projectUrlStr: REPO_URL),
])

def run_type_description = '''
normal - executing all configured build and test stages normally<br>
setup - only reloading configuration, not running futher stages
'''

// Record failed target(s)
def failedTargets = []

Expand Down Expand Up @@ -86,13 +91,44 @@ pipeline {
triggers {
pollSCM('* * * * *')
}
parameters {
choice name: 'RUN_TYPE',
choices: ['normal', 'setup' ],
description: run_type_description
}
options {
disableConcurrentBuilds()
timestamps ()
buildDiscarder(logRotator(numToKeepStr: '100'))
}
stages {

stage('Setup') {
when {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
steps {
script {
String note = 'Project configuration parsed.'
echo note
currentBuild.description = note
currentBuild.result = 'NOT_BUILT'
}
}
}

stage('Checkout') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script { utils = load "utils.groovy" }
dir(WORKDIR) {
Expand All @@ -110,6 +146,14 @@ pipeline {
}

stage('Evaluate') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
dir(WORKDIR) {
script {
Expand All @@ -121,6 +165,14 @@ pipeline {
}

stage('Build targets') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
parallel target_jobs
Expand Down
60 changes: 60 additions & 0 deletions ghaf-nightly-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ properties([
githubProjectProperty(displayName: '', projectUrlStr: REPO_URL),
])

def run_type_description = '''
normal - executing all configured build and test stages normally<br>
setup - only reloading configuration, not running futher stages
'''

def target_jobs = [:]

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -151,6 +156,12 @@ pipeline {
pollSCM('0 23 * * *')
}

parameters {
choice name: 'RUN_TYPE',
choices: ['normal', 'setup' ],
description: run_type_description
}

options {
disableConcurrentBuilds()
timestamps ()
Expand All @@ -159,7 +170,32 @@ pipeline {

stages {

stage('Setup') {
when {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
steps {
script {
String note = 'Project configuration parsed.'
echo note
currentBuild.description = note
currentBuild.result = 'NOT_BUILT'
}
}
}

stage('Checkout') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script { utils = load "utils.groovy" }
dir(WORKDIR) {
Expand All @@ -178,6 +214,14 @@ pipeline {
}

stage('Evaluate') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
dir(WORKDIR) {
script {
Expand All @@ -193,6 +237,14 @@ pipeline {
}

stage('Build targets') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
parallel target_jobs
Expand All @@ -201,6 +253,14 @@ pipeline {
}

stage('Hardware tests') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
targets.each {
Expand Down
66 changes: 66 additions & 0 deletions ghaf-pre-merge-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ properties([
])
])

def run_type_description = '''
normal - executing all configured build and test stages normally<br>
setup - only reloading configuration, not running futher stages
'''

def target_jobs = [:]

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -111,13 +116,42 @@ def targets = [

pipeline {
agent { label 'built-in' }
parameters {
choice name: 'RUN_TYPE',
choices: ['normal', 'setup' ],
description: run_type_description
}
options {
disableConcurrentBuilds()
timestamps ()
buildDiscarder(logRotator(numToKeepStr: '100'))
}
stages {
stage('Setup') {
when {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
steps {
script {
String note = 'Project configuration parsed.'
echo note
currentBuild.description = note
currentBuild.result = 'NOT_BUILT'
}
}
}
stage('Checkenv') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
sh 'set | grep -P "(GITHUB_PR_)"'
// Fail if this build was not triggered by a PR
Expand All @@ -132,6 +166,14 @@ pipeline {
}
}
stage('Checkout') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script { utils = load "utils.groovy" }
dir(WORKDIR) {
Expand Down Expand Up @@ -175,6 +217,14 @@ pipeline {
}
}
stage('Set PR status pending') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
// https://www.jenkins.io/doc/pipeline/steps/github-pullrequest/
Expand All @@ -188,6 +238,14 @@ pipeline {
}

stage('Evaluate') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
dir(WORKDIR) {
script {
Expand All @@ -199,6 +257,14 @@ pipeline {
}

stage('Build targets') {
when {
not {
anyOf {
triggeredBy 'JobDslCause';
environment name: 'RUN_TYPE', value: 'setup'
}
}
}
steps {
script {
parallel target_jobs
Expand Down
Loading

0 comments on commit 0fe53ec

Please sign in to comment.