Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setup stage to only load project configuration #110

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
78 changes: 73 additions & 5 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 Expand Up @@ -227,11 +293,13 @@ pipeline {
}
unsuccessful {
script {
setGitHubPullRequestStatus(
state: 'FAILURE',
context: "${JOB_BASE_NAME}",
message: "Build #${BUILD_NUMBER} failed in ${currentBuild.durationString}",
)
if(currentBuild.result != 'NOT_BUILT') {
setGitHubPullRequestStatus(
state: 'FAILURE',
context: "${JOB_BASE_NAME}",
message: "Build #${BUILD_NUMBER} failed in ${currentBuild.durationString}",
)
}
}
}
}
Expand Down
Loading