ci: refactor Jenkinsfile for clarity

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-10-19 18:49:52 +02:00
parent 8362b93734
commit ebf0f819ac
1 changed files with 47 additions and 54 deletions

View File

@ -3,16 +3,8 @@ library 'status-jenkins-lib@v1.7.13'
pipeline { pipeline {
environment { agent {
QT_QPA_PLATFORMTHEME = "qt5ct" label "${params.AGENT} && x86_64 && qt-5.15.2"
QT_LOGGING_DEBUG = 1
QT_DEBUG_PLUGINS = 1
SQUISH_DIR = "/opt/squish-runner-7.1-20230222-1555"
PYTHONPATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/lib/python:${PYTHONPATH}"
LD_LIBRARY_PATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/python3/lib:${LD_LIBRARY_PATH}"
TESTRAIL_URL = "https://ethstatus.testrail.net"
} }
parameters { parameters {
@ -28,18 +20,6 @@ pipeline {
tagFilter: '*', tagFilter: '*',
type: 'PT_BRANCH' type: 'PT_BRANCH'
) )
choice(
name: 'AGENT',
choices: [
'linux',
'linux-01',
'linux-02',
'linux-03',
'linux-04',
'linux-05',
],
description: 'Agent name to run tests on it.'
)
string( string(
name: 'BUILD_URL', name: 'BUILD_URL',
description: 'Link to tar.gz file.', description: 'Link to tar.gz file.',
@ -60,10 +40,12 @@ pipeline {
description: 'Test run ID in Test Rail.', description: 'Test run ID in Test Rail.',
defaultValue: '' defaultValue: ''
) )
} /* FIXME: This is temporary and should be removed. */
choice(
agent { name: 'AGENT',
label "${params.AGENT} && x86_64 && qt-5.15.2" description: 'Agent name to run tests on it.',
choices: ['linux', 'linux-01', 'linux-02', 'linux-03', 'linux-04', 'linux-05']
)
} }
options { options {
@ -78,27 +60,39 @@ pipeline {
)) ))
} }
environment {
QT_QPA_PLATFORMTHEME = 'qt5ct'
QT_LOGGING_DEBUG = 1
QT_DEBUG_PLUGINS = 1
SQUISH_DIR = '/opt/squish-runner-7.1-20230222-1555'
PYTHONPATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/lib/python:${PYTHONPATH}"
LD_LIBRARY_PATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/python3/lib:${LD_LIBRARY_PATH}"
TESTRAIL_URL = 'https://ethstatus.testrail.net'
}
stages { stages {
stage('Download') { stage('Download') {
steps { steps {
script { script {
sh "mkdir -p './tmp/pkg/'" sh 'mkdir -p ./tmp/pkg/'
if (params.BUILD_URL != "") { if (params.BUILD_URL != '') {
fileOperations([ fileOperations([
fileDownloadOperation( fileDownloadOperation(
url: params.BUILD_URL, url: params.BUILD_URL,
userName: "", userName: '',
password: "", password: '',
targetLocation: "./tmp/pkg/", targetLocation: './tmp/pkg/',
targetFileName: "StatusIm-Desktop.tar.gz", targetFileName: 'StatusIm-Desktop.tar.gz',
) )
]) ])
} else { } else {
copyArtifacts( copyArtifacts(
projectName: "status-desktop/systems/linux/x86_64/package/", projectName: 'status-desktop/systems/linux/x86_64/package/',
filter: 'pkg/*-x86_64.tar.gz', filter: 'pkg/*-x86_64.tar.gz',
selector: lastWithArtifacts(), selector: lastWithArtifacts(),
target: "./tmp" target: './tmp'
) )
} }
def pkg_path = "./${utils.findFile('tmp/pkg/*tar.gz')}" def pkg_path = "./${utils.findFile('tmp/pkg/*tar.gz')}"
@ -115,7 +109,11 @@ pipeline {
} }
stage('Test') { stage('Test') {
steps { steps { script {
def flags = []
if (params.TEST_NAME) { flags.add("-k=${params.TEST_NAME}") }
if (params.TEST_SCOPE) { flags.add("-m=${params.TEST_SCOPE}") }
dir ('configs') { sh 'ln -s _local.ci.py _local.py' }
wrap([ wrap([
$class: 'Xvfb', $class: 'Xvfb',
autoDisplayName: true, autoDisplayName: true,
@ -123,27 +121,22 @@ pipeline {
screen: '1920x1080x24', screen: '1920x1080x24',
additionalOptions: '-dpi 1' additionalOptions: '-dpi 1'
]){ ]){
script { sh 'fluxbox &'
sh "fluxbox &" withCredentials([
def cmd = '' usernamePassword(
if (params.TEST_NAME != "") { credentialsId: 'test-rail-api-devops',
cmd = cmd + " -k ${params.TEST_NAME}" usernameVariable: 'TESTRAIL_USR',
} passwordVariable: 'TESTRAIL_PSW'
if (params.TEST_SCOPE != "") { )
cmd = cmd + " -m ${params.TEST_SCOPE}" ]) {
} sh """
dir ('configs') { sh 'ln -s _local.ci.py _local.py' } python3 -m pytest ${flags.join(" ")} \
withCredentials([ --disable-warnings \
usernamePassword( --alluredir=./allure-results
credentialsId: 'test-rail-api-devops', """
usernameVariable: 'TESTRAIL_USR',
passwordVariable: 'TESTRAIL_PSW')
]) {
sh "python3 -m pytest ${cmd} --disable-warnings --alluredir=./allure-results"
}
} }
} }
} } }
} }
} }
post { post {