From 17d91b5224bcc482ae7ffd7ad3045d0105de5e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 19 Oct 2023 18:49:52 +0200 Subject: [PATCH] ci: refactor Jenkinsfile for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile | 101 +++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 54 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index c4514b1..15adb01 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -3,16 +3,8 @@ library 'status-jenkins-lib@v1.7.13' 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" + agent { + label "${params.AGENT} && x86_64 && qt-5.15.2" } parameters { @@ -28,18 +20,6 @@ pipeline { tagFilter: '*', 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( name: 'BUILD_URL', description: 'Link to tar.gz file.', @@ -60,10 +40,12 @@ pipeline { description: 'Test run ID in Test Rail.', defaultValue: '' ) - } - - agent { - label "${params.AGENT} && x86_64 && qt-5.15.2" + /* FIXME: This is temporary and should be removed. */ + choice( + name: 'AGENT', + description: 'Agent name to run tests on it.', + choices: ['linux', 'linux-01', 'linux-02', 'linux-03', 'linux-04', 'linux-05'] + ) } 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 { stage('Download') { steps { script { - sh "mkdir -p './tmp/pkg/'" - if (params.BUILD_URL != "") { + sh 'mkdir -p ./tmp/pkg/' + if (params.BUILD_URL != '') { fileOperations([ fileDownloadOperation( url: params.BUILD_URL, - userName: "", - password: "", - targetLocation: "./tmp/pkg/", - targetFileName: "StatusIm-Desktop.tar.gz", + userName: '', + password: '', + targetLocation: './tmp/pkg/', + targetFileName: 'StatusIm-Desktop.tar.gz', ) ]) } else { copyArtifacts( - projectName: "status-desktop/systems/linux/x86_64/package/", + projectName: 'status-desktop/systems/linux/x86_64/package/', filter: 'pkg/*-x86_64.tar.gz', selector: lastWithArtifacts(), - target: "./tmp" + target: './tmp' ) } def pkg_path = "./${utils.findFile('tmp/pkg/*tar.gz')}" @@ -115,7 +109,11 @@ pipeline { } 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([ $class: 'Xvfb', autoDisplayName: true, @@ -123,27 +121,22 @@ pipeline { screen: '1920x1080x24', additionalOptions: '-dpi 1' ]){ - script { - sh "fluxbox &" - def cmd = '' - if (params.TEST_NAME != "") { - cmd = cmd + " -k ${params.TEST_NAME}" - } - if (params.TEST_SCOPE != "") { - cmd = cmd + " -m ${params.TEST_SCOPE}" - } - dir ('configs') { sh 'ln -s _local.ci.py _local.py' } - withCredentials([ - usernamePassword( - credentialsId: 'test-rail-api-devops', - usernameVariable: 'TESTRAIL_USR', - passwordVariable: 'TESTRAIL_PSW') - ]) { - sh "python3 -m pytest ${cmd} --disable-warnings --alluredir=./allure-results" - } + sh 'fluxbox &' + withCredentials([ + usernamePassword( + credentialsId: 'test-rail-api-devops', + usernameVariable: 'TESTRAIL_USR', + passwordVariable: 'TESTRAIL_PSW' + ) + ]) { + sh """ + python3 -m pytest ${flags.join(" ")} \ + --disable-warnings \ + --alluredir=./allure-results + """ } } - } + } } } } post {