-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile_qemu
146 lines (135 loc) · 5.18 KB
/
Jenkinsfile_qemu
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*****************************************************************************
* Copyright (C) 2021 Savoir-faire Linux Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*****************************************************************************/
pipeline {
agent any
environment {
TORADEX_REPO_URL = "https://git.toradex.com/toradex-manifest.git \
-b dunfell-5.x.y -m tdxref/default.xml"
YOCTO_CACHE_DIR = "/var/jenkins_home/yocto"
CQFD_EXTRA_RUN_ARGS = "\
-v ${YOCTO_CACHE_DIR}/dl:/mnt/dl \
-e DL_DIR=/mnt/dl \
-v ${YOCTO_CACHE_DIR}/sstate:/mnt/sstate \
-e SSTATE_DIR=/mnt/sstate \
--cap-add=NET_ADMIN \
--network host \
--device /dev/net/tun:/dev/net/tun"
GIT_SSH_COMMAND = "ssh -o StrictHostKeyChecking=no"
ANSIBLE_HOST_KEY_CHECKING = "False"
ANSIBLE_GATHERING = "False"
TARGET_IP = "192.168.7.2" // IP is hardcoded by runqemu script
}
stages {
stage("1. Prepare workspace") {
steps {
cleanWs()
}
}
stage("2. Prepare build environment") {
steps {
script {
stage("2.1. Fetch toradex sources") {
sh """
repo init -u \$TORADEX_REPO_URL
repo sync
"""
}
stage("2.2. Fetch base CI") {
sh """
git clone https://github.com/savoirfairelinux/base_ci.git
"""
}
stage("2.3. Fetch bash tools") {
sh"""
mkdir -p base_ci/cqfd/scripts
cd base_ci/cqfd/scripts
git clone https://github.com/savoirfairelinux/bash_scripting_tools.git
"""
}
stage("2.4. Prepare CQFD") {
sh """
# Move CQFD to root build dir
mv base_ci/cqfd/* .
mv base_ci/cqfd/.cqfd* .
mv layers sources
# Initialize CQFD
cqfd init
"""
}
stage("2.5. Fetch cukinia repo") {
sh"""
git clone https://github.com/savoirfairelinux/cukinia.git
"""
}
}
}
}
stage("3. Build image") {
steps {
script {
sh """
cqfd run ./build.sh -v -m qemux86-64 --distro tdx-x11 \
-i tdx-reference-minimal-image \
-- echo "source poky environment"
echo 'CORE_IMAGE_EXTRA_INSTALL += "python3"' >> build/conf/local.conf
cqfd run ./build.sh -v -m qemux86-64 \
--distro tdx-x11 -i tdx-reference-minimal-image
"""
}
}
}
stage("4. Launch image") {
steps {
script {
sh"""
cqfd run ./build.sh -v -m qemux86-64 --distro tdx-x11 \
-i tdx-reference-minimal-image \
-- runqemu qemux86-64 nographic &
cd base_ci/ansible
ansible -vvv all -i \${TARGET_IP}, \
-m ansible.builtin.wait_for_connection -u root
"""
}
}
}
stage("5. Test") {
steps {
script {
sh"""
# Pass tests
cd base_ci/ansible
ansible-playbook -vvv playbooks/ci_common_tests.yaml \
-i inventories/target_machine.yaml \
-e rootfs_name_var=rootfs \
-e target_ip=\${TARGET_IP}
# Shutdown the target after the test
ansible -vvv all -i \${TARGET_IP}, \
-m raw -a "/sbin/shutdown -h now" -u root
"""
junit "base_ci/ansible/playbooks/common/cukinia_common.xml"
}
}
}
}
post {
success {
echo "Test succeed."
}
failure {
echo "Pipeline failed."
}
}
}