From 5566dd2968d9f4fd99b2346bb5757842507f2993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Dallidet?= Date: Thu, 21 Nov 2024 12:06:28 +0100 Subject: [PATCH] Fixes #25919: Rework the jenkinsfile of the repo --- Jenkinsfile | 86 ++++++++++++++++++++++++++++------------ ci/shellcheck.Dockerfile | 4 ++ ci/typos.Dockerfile | 5 +++ ci/user.sh | 7 ++++ 4 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 ci/shellcheck.Dockerfile create mode 100644 ci/typos.Dockerfile create mode 100755 ci/user.sh diff --git a/Jenkinsfile b/Jenkinsfile index bd13c910c..e01848d26 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,38 +3,74 @@ import org.gradiant.jenkins.slack.SlackNotifier pipeline { agent none - stages { stage('Tests') { - parallel { - stage('shell') { - agent { label 'script' } - steps { - sh script: 'typos', label: 'check typos' - sh script: './qa-test --shell', label: 'shell scripts lint' + stage('typos') { + agent { + dockerfile { + filename 'ci/typos.Dockerfile' + } + steps { + sh script: 'typos', label: 'check typos' + } + post { + failure { + script { + errors.add("check typos") + slackResponse = updateSlack(errors, running, slackResponse, version, changeUrl) + slackSend(channel: slackResponse.threadId, message: "Check typos on all plugins failed - <${currentBuild.absoluteUrl}console|Console>", color: "#CC3421") + } } - post { - always { - // linters results - recordIssues enabledForFailure: true, failOnError: true, sourceCodeEncoding: 'UTF-8', - tool: checkStyle(pattern: '.shellcheck/*.log', reportEncoding: 'UTF-8', name: 'Shell scripts') - - script { - new SlackNotifier().notifyResult("shell-team") - } + cleanup { + script { + running.remove("check typos") } } } - stage('python') { - agent { label 'script' } - steps { - sh script: './qa-test --python', label: 'python scripts lint' + } + stage('shellcheck') { + agent { + dockerfile { + filename 'ci/shellcheck.Dockerfile' + } + steps { + sh script: './qa-test --shell', label: 'shellcheck' + } + post { + always { + // linters results + recordIssues enabledForFailure: true, failOnError: true, sourceCodeEncoding: 'UTF-8', + tool: checkStyle(pattern: '.shellcheck/*.log', reportEncoding: 'UTF-8', name: 'Shell scripts') + } + failure { + script { + errors.add("shell scripts") + slackResponse = updateSlack(errors, running, slackResponse, version, changeUrl) + slackSend(channel: slackResponse.threadId, message: "Check shell scripts on all plugins failed - <${currentBuild.absoluteUrl}console|Console>", color: "#CC3421") + } + } + } + } + stage('python') { + agent { + dockerfile { + filename 'ci/pylint.Dockerfile' + } + } + steps { + sh script: './qa-test --python', label: 'python scripts lint' + } + post { + failure { + script { + errors.add("python scripts") + slackResponse = updateSlack(errors, running, slackResponse, version, changeUrl) + slackSend(channel: slackResponse.threadId, message: "Check python scripts on all plugins failed - <${currentBuild.absoluteUrl}console|Console>", color: "#CC3421") + } } - post { - always { - script { - new SlackNotifier().notifyResult("shell-team") - } + cleanup { + script { + running.remove("python scripts") } } } diff --git a/ci/shellcheck.Dockerfile b/ci/shellcheck.Dockerfile new file mode 100644 index 000000000..72f613443 --- /dev/null +++ b/ci/shellcheck.Dockerfile @@ -0,0 +1,4 @@ +FROM debian:12 +LABEL ci=rudder/ci/shellcheck.Dockerfile + +RUN apt-get update && apt-get install -y shellcheck diff --git a/ci/typos.Dockerfile b/ci/typos.Dockerfile new file mode 100644 index 000000000..681a985bf --- /dev/null +++ b/ci/typos.Dockerfile @@ -0,0 +1,5 @@ +FROM rust:1.74.0 +LABEL ci=rudder/ci/typos.Dockerfile +ARG VERSION + +RUN cargo install -f typos-cli --locked --version =$VERSION diff --git a/ci/user.sh b/ci/user.sh new file mode 100755 index 000000000..79d7ab99b --- /dev/null +++ b/ci/user.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Jenkins user with correct uid +USER_ID=$1 +mkdir /home/jenkins +useradd -r -u $USER_ID -d /home/jenkins jenkins +chown jenkins /home/jenkins