diff --git a/Jenkinsfile b/Jenkinsfile index bd13c910..e01848d2 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 00000000..72f61344 --- /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 00000000..681a985b --- /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 00000000..79d7ab99 --- /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