Skip to content

Commit bf9140d

Browse files
Wild8illthst-nordic
authored andcommitted
ci: Move Jenkinsfile to CI-CFG
Move the body of the Jenkinsfile to the test-ci-nrfconnect-cfg repo, and replace with a stub. Signed-off-by: William Hamshaw <William.Hamshaw@nordicsemi.no>
1 parent f8b6ab4 commit bf9140d

File tree

1 file changed

+2
-223
lines changed

1 file changed

+2
-223
lines changed

Jenkinsfile

+2-223
Original file line numberDiff line numberDiff line change
@@ -1,226 +1,5 @@
1-
//
2-
// Copyright (c) 2018 Nordic Semiconductor ASA. All Rights Reserved.
3-
//
4-
// The information contained herein is confidential property of Nordic Semiconductor ASA.
5-
// The use, copying, transfer or disclosure of such information is prohibited except by
6-
// express written agreement with Nordic Semiconductor ASA.
7-
//
8-
91
@Library("CI_LIB") _
10-
HashMap CI_STATE = lib_State.getConfig(JOB_NAME)
11-
properties(lib_State.getTriggers())
12-
13-
def TestExecutionList = [:]
14-
15-
pipeline {
16-
17-
parameters {
18-
booleanParam(name: 'RUN_DOWNSTREAM', description: 'if false skip downstream jobs', defaultValue: true)
19-
booleanParam(name: 'RUN_TESTS', description: 'if false skip testing', defaultValue: true)
20-
booleanParam(name: 'RUN_BUILD', description: 'if false skip building', defaultValue: true)
21-
string(name: 'PLATFORMS', description: 'Default Platforms to test', defaultValue: 'nrf9160dk_nrf9160 nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf5340pdk_nrf5340_cpuapp')
22-
string(name: 'jsonstr_CI_STATE', description: 'Default State if no upstream job', defaultValue: CI_STATE.CFG.INPUT_STATE_STR)
23-
choice(name: 'CRON', choices: ['COMMIT', 'NIGHTLY', 'WEEKLY'], description: 'Cron Test Phase')
24-
}
25-
agent none
26-
27-
options {
28-
parallelsAlwaysFailFast()
29-
timeout(time: CI_STATE.CFG.TIMEOUT.time, unit: CI_STATE.CFG.TIMEOUT.unit)
30-
}
31-
32-
environment {
33-
GH_TOKEN = credentials('nordicbuilder-compliance-token') // This token is used to by check_compliance to comment on PRs and use checks
34-
GH_USERNAME = "NordicBuilder"
35-
COMPLIANCE_ARGS = "-r nrfconnect/sdk-nrf"
36-
ARCH = "-a arm"
37-
SANITYCHECK_OPTIONS_COMMON = '''--ninja \
38-
--board-root nrf/boards \
39-
--testcase-root nrf/samples \
40-
--testcase-root nrf/applications \
41-
--testcase-root nrf/tests \
42-
--inline-logs --disable-unrecognized-section-test \
43-
--tag ci_build \
44-
--retry-failed 7 \
45-
'''
46-
}
47-
48-
stages {
49-
stage('Load') {
50-
agent { label CI_STATE.CFG.AGENT_LABELS }
51-
steps { script { CI_STATE = lib_State.load('NRF', CI_STATE) }}
52-
}
53-
stage('Specification') { steps { script {
54-
def TestStages = [:]
55-
TestStages["compliance"] = {
56-
node (CI_STATE.CFG.AGENT_LABELS) {
57-
stage('Compliance Test'){
58-
println "Using Node:$NODE_NAME"
59-
docker.image("$CI_STATE.CFG.DOCKER_REG/$CI_STATE.CFG.IMAGE_TAG").inside {
60-
dir('nrf') {
61-
checkout scm
62-
CI_STATE.SELF.REPORT_SHA = lib_Main.checkoutRepo(
63-
CI_STATE.SELF.GIT_URL, "NRF", CI_STATE.SELF, false)
64-
lib_Status.set("PENDING", 'NRF', CI_STATE);
65-
lib_West.AddManifestUpdate("NRF", 'nrf',
66-
CI_STATE.SELF.GIT_URL, CI_STATE.SELF.GIT_REF, CI_STATE)
67-
}
68-
lib_West.InitUpdate('nrf')
69-
lib_West.ApplyManifestUpdates(CI_STATE)
70-
71-
dir('nrf') {
72-
script {
73-
// If we're a pull request, compare the target branch against the current HEAD (the PR), and also report issues to the PR
74-
def BUILD_TYPE = lib_Main.getBuildType(CI_STATE.SELF)
75-
if (BUILD_TYPE == "PR") {
76-
COMMIT_RANGE = "$CI_STATE.SELF.MERGE_BASE..$CI_STATE.SELF.REPORT_SHA"
77-
COMPLIANCE_ARGS = "$COMPLIANCE_ARGS $CI_STATE.SELF.CUSTOM_COMPLIANCE_ARGS -p $CHANGE_ID -S $CI_STATE.SELF.REPORT_SHA"
78-
println "Building a PR [$CHANGE_ID]: $COMMIT_RANGE"
79-
}
80-
else if (BUILD_TYPE == "TAG") {
81-
COMMIT_RANGE = "tags/${env.BRANCH_NAME}..tags/${env.BRANCH_NAME}"
82-
println "Building a Tag: " + COMMIT_RANGE
83-
}
84-
// If not a PR, it's a non-PR-branch or master build. Compare against the origin.
85-
else if (BUILD_TYPE == "BRANCH") {
86-
COMMIT_RANGE = "origin/${env.BRANCH_NAME}..HEAD"
87-
println "Building a Branch: " + COMMIT_RANGE
88-
}
89-
else {
90-
assert condition : "Build fails because it is not a PR/Tag/Branch"
91-
}
92-
93-
// Run the compliance check
94-
try {
95-
sh """ \
96-
(source ../zephyr/zephyr-env.sh && \
97-
pip install --user -r ../tools/ci-tools/requirements.txt && \
98-
pip install --user pylint && \
99-
echo "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>" > compliance.xml
100-
echo "<testsuites errors=\\"0\\" failures=\\"0\\" tests=\\"1\\">" >> compliance.xml
101-
echo "<testsuite errors=\\"0\\" failures=\\"0\\" tests=\\"1\\">" >> compliance.xml
102-
echo "<testcase classname=\\"nop\\" name=\\"nop\\"/>" >> compliance.xml
103-
echo "</testsuite>" >> compliance.xml
104-
echo "</testsuites>" >> compliance.xml)
105-
"""
106-
}
107-
finally {
108-
junit 'compliance.xml'
109-
archiveArtifacts artifacts: 'compliance.xml'
110-
lib_Main.storeArtifacts("compliance", 'compliance.xml', 'NRF', CI_STATE)
111-
}
112-
}
113-
}
114-
}
115-
cleanWs()
116-
}
117-
}
118-
}
119-
120-
if (CI_STATE.SELF.CRON == 'COMMIT') {
121-
println "Running Commit Tests"
122-
} else if (CI_STATE.SELF.CRON == 'NIGHTLY') {
123-
println "Running Nightly Tests"
124-
} else if (CI_STATE.SELF.CRON == 'WEEKLY') {
125-
println "Running Weekly Tests"
126-
}
127-
128-
def PLATFORM_LIST = lib_Main.getPlatformList(CI_STATE.SELF.PLATFORMS)
129-
130-
def COMPILER_LIST = ['gnuarmemb'] //'zephyr',
131-
def INPUT_MAP = [p : PLATFORM_LIST, c : COMPILER_LIST ]
132-
def PLATFORM_COMPILER_MAP = INPUT_MAP.values().combinations { args ->
133-
[INPUT_MAP.keySet().toList(), args].transpose().collectEntries { [(it[0]): it[1]]}
134-
}
135-
136-
def sanityCheckStages = PLATFORM_COMPILER_MAP.collectEntries {
137-
["SanityCheck\n${it.c}\n${it.p}" : generateParallelStage(it.p, it.c, JOB_NAME, CI_STATE, SANITYCHECK_OPTIONS_COMMON)]
138-
}
139-
140-
if (CI_STATE.SELF.RUN_TESTS) {
141-
TestExecutionList['compliance'] = TestStages["compliance"]
142-
}
143-
144-
if (CI_STATE.SELF.RUN_BUILD) {
145-
TestExecutionList = TestExecutionList.plus(sanityCheckStages)
146-
}
147-
148-
println "TestExecutionList = $TestExecutionList"
149-
150-
}}}
151-
152-
stage('Execution') { steps { script {
153-
parallel TestExecutionList
154-
// FilePath context variable is required to send Github notifications
155-
node(CI_STATE.CFG.AGENT_LABELS) {
156-
lib_Status.set("${currentBuild.currentResult}", 'NRF', CI_STATE)
157-
}
158-
}}}
159-
160-
stage('Trigger Downstream Jobs') {
161-
when { expression { CI_STATE.SELF.RUN_DOWNSTREAM } }
162-
steps { script { lib_Stage.runDownstream(JOB_NAME, CI_STATE) } }
163-
}
164-
165-
stage('Report') {
166-
when { expression { CI_STATE.SELF.RUN_TESTS } }
167-
steps { script {
168-
println 'no report generation yet'
169-
} }
170-
}
171-
}
172-
post {
173-
// This is the order that the methods are run. {always->success/abort/failure/unstable->cleanup}
174-
always {
175-
script {
176-
echo "always";
177-
// FilePath context variable is required to send Github notifications
178-
node(CI_STATE.CFG.AGENT_LABELS) {
179-
lib_Status.set( "${currentBuild.currentResult}" , 'FULL_CI', CI_STATE)
180-
}
181-
}
182-
}
183-
184-
/* uncomment if logic is needed
185-
success { }
186-
aborted { }
187-
unstable { }
188-
failure { }
189-
cleanup { }
190-
*/
191-
}
192-
}
1932

3+
def pipeline = new ncs.sdk_nrf.Main()
1944

195-
def generateParallelStage(platform, compiler, JOB_NAME, CI_STATE, SANITYCHECK_OPTIONS_COMMON) {
196-
return {
197-
node (CI_STATE.CFG.AGENT_LABELS) {
198-
stage('.'){
199-
println "Using Node:$NODE_NAME"
200-
docker.image("$CI_STATE.CFG.DOCKER_REG/$CI_STATE.CFG.IMAGE_TAG").inside {
201-
dir('nrf') {
202-
checkout scm
203-
CI_STATE.SELF.REPORT_SHA = lib_Main.checkoutRepo(
204-
CI_STATE.SELF.GIT_URL, "NRF", CI_STATE.SELF, false)
205-
lib_West.AddManifestUpdate("NRF", 'nrf',
206-
CI_STATE.SELF.GIT_URL, CI_STATE.SELF.GIT_REF, CI_STATE)
207-
}
208-
lib_West.InitUpdate('nrf')
209-
lib_West.ApplyManifestUpdates(CI_STATE)
210-
PLATFORM_ARGS = lib_Main.getPlatformArgs(platform)
211-
SANITYCHECK_CMD = "./zephyr/scripts/sanitycheck $SANITYCHECK_OPTIONS_COMMON $PLATFORM_ARGS"
212-
FULL_SANITYCHECK_CMD = """
213-
export ZEPHYR_TOOLCHAIN_VARIANT='$compiler' && \
214-
source zephyr/zephyr-env.sh && \
215-
pip install --user -r nrf/scripts/requirements-ci.txt && \
216-
export && \
217-
$SANITYCHECK_CMD
218-
"""
219-
println "FULL_SANITYCHECK_CMD = " + FULL_SANITYCHECK_CMD
220-
sh FULL_SANITYCHECK_CMD
221-
}
222-
cleanWs()
223-
}
224-
}
225-
}
226-
}
5+
pipeline.run(JOB_NAME)

0 commit comments

Comments
 (0)