|
| 1 | +#!/usr/bin/env groovy |
| 2 | +/* beacon_chain |
| 3 | + * Copyright (c) 2019-2024 Status Research & Development GmbH |
| 4 | + * Licensed and distributed under either of |
| 5 | + * * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). |
| 6 | + * * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). |
| 7 | + * at your option. This file may not be copied, modified, or distributed except according to those terms. |
| 8 | + */ |
| 9 | + |
| 10 | + |
| 11 | +pipeline { |
| 12 | + /* This way we run the same Jenkinsfile on different platforms. */ |
| 13 | + agent { label params.AGENT_LABEL } |
| 14 | + |
| 15 | + parameters { |
| 16 | + string( |
| 17 | + name: 'AGENT_LABEL', |
| 18 | + description: 'Label for targetted CI slave host: linux/macos', |
| 19 | + defaultValue: params.AGENT_LABEL ?: getAgentLabel(), |
| 20 | + ) |
| 21 | + choice( |
| 22 | + name: 'VERBOSITY', |
| 23 | + description: 'Value for the V make flag to increase log verbosity', |
| 24 | + choices: [0, 1, 2] |
| 25 | + ) |
| 26 | + } |
| 27 | + |
| 28 | + options { |
| 29 | + timestamps() |
| 30 | + ansiColor('xterm') |
| 31 | + /* This also includes wait time in the queue. */ |
| 32 | + timeout(time: 1, unit: 'HOURS') |
| 33 | + /* Limit builds retained. */ |
| 34 | + buildDiscarder(logRotator( |
| 35 | + numToKeepStr: '5', |
| 36 | + daysToKeepStr: '30', |
| 37 | + )) |
| 38 | + /* Abort old builds for non-main branches. */ |
| 39 | + disableConcurrentBuilds( |
| 40 | + abortPrevious: !isMainBranch() |
| 41 | + ) |
| 42 | + } |
| 43 | + |
| 44 | + stages { |
| 45 | + stage('Beacon Node') { |
| 46 | + steps { script { |
| 47 | + nix.flake('beacon_node') |
| 48 | + } } |
| 49 | + } |
| 50 | + |
| 51 | + stage('Version check') { |
| 52 | + steps { script { |
| 53 | + sh 'result/bin/nimbus_beacon_node --version' |
| 54 | + } } |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + post { |
| 59 | + always { |
| 60 | + cleanWs( |
| 61 | + disableDeferredWipeout: true, |
| 62 | + deleteDirs: true |
| 63 | + ) |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +def isMainBranch() { |
| 69 | + return ['stable', 'testing', 'unstable'].contains(env.BRANCH_NAME) |
| 70 | +} |
| 71 | + |
| 72 | +/* This allows us to use one Jenkinsfile and run |
| 73 | + * jobs on different platforms based on job name. */ |
| 74 | +def getAgentLabel() { |
| 75 | + if (params.AGENT_LABEL) { return params.AGENT_LABEL } |
| 76 | + /* We extract the name of the job from currentThread because |
| 77 | + * before an agent is picket env is not available. */ |
| 78 | + def tokens = Thread.currentThread().getName().split('/') |
| 79 | + def labels = [] |
| 80 | + /* Check if the job path contains any of the valid labels. */ |
| 81 | + ['linux', 'macos', 'x86_64', 'aarch64', 'arm64'].each { |
| 82 | + if (tokens.contains(it)) { labels.add(it) } |
| 83 | + } |
| 84 | + return labels.join(' && ') |
| 85 | +} |
0 commit comments