From 6a58b9cde2882d1f0996a5329823bb3a6e03011b Mon Sep 17 00:00:00 2001
From: EEA Jenkins <eea-jenkins@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:59:46 +0300
Subject: [PATCH 1/3] Add Sonarqube tag using clms-frontend addons list

---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 32c1ee7..a3ba7f6 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -4,7 +4,7 @@ pipeline {
   environment {
         GIT_NAME = "volto-call-to-action-block"
         NAMESPACE = "@eeacms"
-        SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu,water.europa.eu-freshwater"
+        SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu,water.europa.eu-freshwater,land.copernicus.eu"
         DEPENDENCIES = ""
         VOLTO = "16"
     }

From 478cf6c50122dada7bb1f7859bd8e9795828db49 Mon Sep 17 00:00:00 2001
From: valentinab25 <valentinab25>
Date: Tue, 31 Oct 2023 02:29:56 +0200
Subject: [PATCH 2/3] chore: [JENKINS] Refactor automated testing

---
 Dockerfile  |   2 +-
 Jenkinsfile | 286 ++++++++++++++++++++++++++++------------------------
 Makefile    |  37 ++++++-
 3 files changed, 188 insertions(+), 137 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index bd8e10d..b1ce603 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,6 @@
 # syntax=docker/dockerfile:1
 ARG VOLTO_VERSION
-FROM plone/frontend-builder:${VOLTO_VERSION}
+FROM eeacms/frontend-builder:${VOLTO_VERSION}
 
 ARG ADDON_NAME
 ARG ADDON_PATH
diff --git a/Jenkinsfile b/Jenkinsfile
index a3ba7f6..591dad2 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,16 +1,20 @@
 pipeline {
-  agent any
+  agent {
+    node { label 'docker-host' }
+  }
 
   environment {
-        GIT_NAME = "volto-call-to-action-block"
-        NAMESPACE = "@eeacms"
-        SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu,water.europa.eu-freshwater,land.copernicus.eu"
-        DEPENDENCIES = ""
-        VOLTO = "16"
-    }
+    GIT_NAME = "volto-call-to-action-block"
+    NAMESPACE = "@eeacms"
+    SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu,water.europa.eu-freshwater,land.copernicus.eu"
+    DEPENDENCIES = ""
+    BACKEND_PROFILES = "eea.kitkat:testing"
+    BACKEND_ADDONS = ""
+    VOLTO = "16"
+    IMAGE_NAME = BUILD_TAG.toLowerCase()
+  }
 
   stages {
-
     stage('Release') {
       when {
         allOf {
@@ -20,52 +24,41 @@ pipeline {
       }
       steps {
         node(label: 'docker') {
-          withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
-            sh '''docker pull eeacms/gitflow'''
-            sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
+          withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
+            sh '''docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
           }
         }
       }
     }
 
-    stage('Code') {
+    stage('Check if testing needed') {
       when {
         allOf {
-          environment name: 'CHANGE_ID', value: ''
-          not { changelog '.*^Automated release [0-9\\.]+$' }
           not { branch 'master' }
+          not { branch 'develop' }
+          environment name: 'CHANGE_ID', value: ''
         }
       }
       steps {
-        parallel(
-
-          "ES lint": {
-            node(label: 'docker') {
-              sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci eslint'''
-            }
-          },
-
-          "Style lint": {
-            node(label: 'docker') {
-              sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci stylelint'''
-            }
-          },
+        script {
+            withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
+              check_result = sh script: '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-check" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /check_if_testing_needed.sh''', returnStatus: true
 
-          "Prettier": {
-            node(label: 'docker') {
-              sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci prettier'''
+              if (check_result == 0) {
+                env.SKIP_TESTS = 'yes'
+              }
             }
-          }
-        )
+        }
       }
     }
 
-    stage('Tests') {
+    stage('Testing') {
       when {
         anyOf {
           allOf {
             not { environment name: 'CHANGE_ID', value: '' }
             environment name: 'CHANGE_TARGET', value: 'develop'
+            environment name: 'SKIP_TESTS', value: ''
           }
           allOf {
             environment name: 'CHANGE_ID', value: ''
@@ -73,26 +66,76 @@ pipeline {
               not { changelog '.*^Automated release [0-9\\.]+$' }
               branch 'master'
             }
+            environment name: 'SKIP_TESTS', value: ''
           }
         }
       }
-      steps {
-        parallel(
+      stages {
+        stage('Build test image') {
+          steps {
+            checkout scm
+            sh '''docker build --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME"  --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend'''
+          }
+        }
+        
+        stage('Fix code') {
+          when {
+              environment name: 'CHANGE_ID', value: ''
+              not { branch 'master' }
+          }
+          steps {
+            script {
+              fix_result = sh(script: '''docker run --name="$IMAGE_NAME-fix" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME  $IMAGE_NAME-frontend ci-fix''', returnStatus: true)
+              sh '''docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .'''
+              sh '''docker rm -v $IMAGE_NAME-fix'''
+              FOUND_FIX = sh(script: '''git diff | wc -l''', returnStdout: true).trim()
 
-          "Volto": {
-            node(label: 'docker') {
-              script {
-                try {
-                  sh '''docker pull plone/volto-addon-ci'''
-                  sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci'''
-                  sh '''rm -rf xunit-reports'''
-                  sh '''mkdir -p xunit-reports'''
-                  sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/'''
-                  sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/'''
-                  sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/'''
-                  stash name: "xunit-reports", includes: "xunit-reports/**"
-                  archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true
-                  publishHTML (target : [
+              if (FOUND_FIX != '0') {
+                withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
+                  sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config'''
+                }
+                sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH'''
+                sh '''git checkout $GIT_BRANCH'''
+                sh '''git add src/'''
+                sh '''git commit -m "style: Automated code fix" '''
+                sh '''git push --set-upstream origin $GIT_BRANCH'''
+                sh '''exit 1'''
+              }
+            }
+          }
+        }
+
+        stage('ES lint') {
+          steps {
+            sh '''docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
+          }
+        }
+
+        stage('Style lint') {
+          steps {
+            sh '''docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME  $IMAGE_NAME-frontend stylelint'''
+          }
+        }
+
+        stage('Prettier') {
+          steps {
+            sh '''docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME  $IMAGE_NAME-frontend prettier'''
+          }
+        }
+
+        stage('Coverage Tests') {
+          parallel {
+            
+            stage('Unit tests') {
+              steps {
+                script {
+                  try {
+                    sh '''docker run --name="$IMAGE_NAME-volto" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend test-ci'''
+                    sh '''rm -rf xunit-reports'''
+                    sh '''mkdir -p xunit-reports'''
+                    sh '''docker cp $IMAGE_NAME-volto:/app/coverage xunit-reports/'''
+                    sh '''docker cp $IMAGE_NAME-volto:/app/junit.xml xunit-reports/'''
+                    publishHTML(target : [
                     allowMissing: false,
                     alwaysLinkToLastBuild: true,
                     keepAll: true,
@@ -105,75 +148,60 @@ pipeline {
                     catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
                         junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true
                     }
-                   sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true
+                    sh script: '''docker rm -v $IMAGE_NAME-volto''', returnStatus: true
+                  }
                 }
               }
             }
-          }
-        )
-      }
-    }
+            
+            stage('Integration tests') {
+              steps {
+                script {
+                  try {
+                    sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
+                    sh '''docker run --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci'''
+                  } finally {
+                    try {
+                      sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots'''
+                      sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots'''
+                      sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/'''
+                      sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/'''
+                      screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true
 
-    stage('Integration tests') {
-      when {
-        anyOf {
-          allOf {
-            not { environment name: 'CHANGE_ID', value: '' }
-            environment name: 'CHANGE_TARGET', value: 'develop'
-          }
-          allOf {
-            environment name: 'CHANGE_ID', value: ''
-            anyOf {
-              not { changelog '.*^Automated release [0-9\\.]+$' }
-              branch 'master'
-            }
-          }
-        }
-      }
-      steps {
-        parallel(
+                      archiveArtifacts artifacts: 'cypress-screenshots/**', fingerprint: true, allowEmptyArchive: true
 
-          "Cypress": {
-            node(label: 'docker') {
-              script {
-                try {
-                  sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
-                  sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e VOLTO=$VOLTO plone/volto-addon-ci cypress'''
-                } finally {
-                  try {
-                    sh '''rm -rf cypress-reports cypress-results cypress-coverage'''
-                    sh '''mkdir -p cypress-reports cypress-results cypress-coverage'''
-                    sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/'''
-                    sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/'''
-                    coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true
-                    if ( coverage == 0 ) {
-                         publishHTML (target : [allowMissing: false,
+                      coverage = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/coverage cypress-coverage''', returnStatus: true
+
+                      if ( coverage == 0 ) {
+                        publishHTML(target : [allowMissing: false,
                              alwaysLinkToLastBuild: true,
                              keepAll: true,
                              reportDir: 'cypress-coverage/coverage/lcov-report',
                              reportFiles: 'index.html',
                              reportName: 'CypressCoverage',
                              reportTitles: 'Integration Tests Code Coverage'])
-                    }
-                    sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done'''
-                    archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true
-                    stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true
-                  }
-                  finally {
-                    catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
+                      }
+                      sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' );  rm -f cypress-videos/videos/$testname.mp4; fi; done'''
+                      archiveArtifacts artifacts: 'cypress-videos/**', fingerprint: true, allowEmptyArchive: true
+                    } finally {
+                      catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
                         junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true
+                      }
+                      sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true
+                      sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true
+                      sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true
                     }
-                    sh script: "docker stop $BUILD_TAG-plone", returnStatus: true
-                    sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true
-                    sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true
-
                   }
                 }
               }
             }
           }
-
-        )
+        }
+      }
+      post {
+        always {
+            sh script: "docker rmi $IMAGE_NAME-frontend", returnStatus: true
+        }
       }
     }
 
@@ -197,19 +225,16 @@ pipeline {
         }
       }
       steps {
-        node(label: 'swarm') {
-          script{
-            checkout scm
-            unstash "xunit-reports"
-            unstash "cypress-coverage"
-            def scannerHome = tool 'SonarQubeScanner';
-            def nodeJS = tool 'NodeJS';
-            withSonarQubeEnv('Sonarqube') {
-              sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
-              sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
-              sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
-              sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
-            }
+        script {
+          def scannerHome = tool 'SonarQubeScanner'
+          def nodeJS = tool 'NodeJS'
+          withSonarQubeEnv('Sonarqube') {
+            sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
+            sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
+            sh '''cat xunit-reports/coverage/lcov.info'''
+            sh '''cat cypress-coverage/coverage/lcov.info'''
+            sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
+            sh '''try=5; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 15; try=\$(( \$try - 1 )); fi; done'''
           }
         }
       }
@@ -230,18 +255,15 @@ pipeline {
         }
       }
       steps {
-        node(label: 'docker') {
-          script {
-            sh '''docker pull eeacms/gitflow'''
-            sh '''echo "Error" > checkresult.txt'''
-            catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
-               sh '''set -o pipefail; docker run -i --rm --name="$BUILD_TAG-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt'''
-             }
-
-            publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: "Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed",
-                          text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
-                          detailsURL: "${env.BUILD_URL}display/redirect"
+        script {
+          sh '''echo "Error" > checkresult.txt'''
+          catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
+            sh '''set -o pipefail; docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt'''
           }
+
+          publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: 'Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed',
+                        text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
+                        detailsURL: "${env.BUILD_URL}display/redirect"
         }
       }
     }
@@ -254,20 +276,16 @@ pipeline {
         environment name: 'CHANGE_TARGET', value: 'master'
       }
       steps {
-        node(label: 'docker') {
-          script {
-            if ( env.CHANGE_BRANCH != "develop" ) {
-                error "Pipeline aborted due to PR not made from develop branch"
-            }
-           withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
-            sh '''docker pull eeacms/gitflow'''
-            sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow'''
-           }
+        script {
+          if (env.CHANGE_BRANCH != 'develop') {
+            error 'Pipeline aborted due to PR not made from develop branch'
+          }
+          withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
+            sh '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow'''
           }
         }
       }
     }
-
   }
 
   post {
diff --git a/Makefile b/Makefile
index f3614a8..6e221b3 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,11 @@ VOLTO_VERSION?=16
 ADDON_PATH="${DIR}"
 ADDON_NAME="@eeacms/${ADDON_PATH}"
 DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose
+RAZZLE_INTERNAL_API_PATH?="${RAZZLE_DEV_PROXY_API_PATH}"
+RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}"
+CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}"
+
+
 
 # Top-level targets
 .PHONY: all
@@ -77,11 +82,11 @@ shell:			## Start a shell in the frontend container
 
 .PHONY: cypress-open
 cypress-open:		## Open cypress integration tests
-	NODE_ENV=development  $(NODE_MODULES)/cypress/bin/cypress open
+	CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development  $(NODE_MODULES)/cypress/bin/cypress open
 
 .PHONY: cypress-run
 cypress-run:	## Run cypress integration tests
-	NODE_ENV=development  $(NODE_MODULES)/cypress/bin/cypress run
+	CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development  $(NODE_MODULES)/cypress/bin/cypress run
 
 .PHONY: test
 test:			## Run jest tests
@@ -129,3 +134,31 @@ i18n:			## i18n
 help:                   ## Show this help.
 	@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
 	head -n 14 Makefile
+
+.PHONY: ci-fix
+ci-fix:
+	echo "Running lint-fix"
+	make lint-fix
+	echo "Running prettier-fix"
+	make prettier-fix
+	echo "Running stylelint-fix"
+	make stylelint-fix
+
+.PHONY: test-ci
+test-ci:
+	cd /app
+	RAZZLE_JEST_CONFIG=src/addons/${ADDON_PATH}/jest-addon.config.js CI=true yarn test src/addons/${ADDON_PATH}/src --watchAll=false --reporters=default --reporters=jest-junit --collectCoverage --coverageReporters lcov cobertura text
+
+.PHONY: start-ci
+start-ci:
+	cd ../..
+	yarn start &
+
+.PHONY: cypress-ci
+cypress-ci:
+	cp .coverage.babel.config.js /app/babel.config.js
+	make start-ci
+	$(NODE_MODULES)/.bin/wait-on -t 240000  http://localhost:3000
+	NODE_ENV=development make cypress-run
+
+

From be02b53782ae016943abc9cf1ee6455175754489 Mon Sep 17 00:00:00 2001
From: EEA Jenkins <@users.noreply.github.com>
Date: Thu, 2 Nov 2023 11:31:41 +0000
Subject: [PATCH 3/3] Automated release 4.2.2

---
 CHANGELOG.md | 12 ++++++++++++
 package.json |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed46c68..69e9796 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d
 
 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
 
+### [4.2.2](https://github.com/eea/volto-call-to-action-block/compare/4.2.1...4.2.2) - 2 November 2023
+
+#### :house: Internal changes
+
+- chore: [JENKINS] Refactor automated testing [valentinab25 - [`478cf6c`](https://github.com/eea/volto-call-to-action-block/commit/478cf6c50122dada7bb1f7859bd8e9795828db49)]
+- chore: husky, lint-staged use fixed versions [valentinab25 - [`67f68bc`](https://github.com/eea/volto-call-to-action-block/commit/67f68bcc6fde8888cb44b0c483b4c1933d207e54)]
+- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`e958386`](https://github.com/eea/volto-call-to-action-block/commit/e95838603735d0ebfa7829359d1503a4e06a39ac)]
+
+#### :hammer_and_wrench: Others
+
+- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`6a58b9c`](https://github.com/eea/volto-call-to-action-block/commit/6a58b9cde2882d1f0996a5329823bb3a6e03011b)]
+- Update README.md [ana-oprea - [`f9b73a5`](https://github.com/eea/volto-call-to-action-block/commit/f9b73a50664cf4a4f1292eb2d5a93dd156e70639)]
 ### [4.2.1](https://github.com/eea/volto-call-to-action-block/compare/4.2.0...4.2.1) - 29 September 2023
 
 #### :house: Documentation changes
diff --git a/package.json b/package.json
index 7af066c..7bcf70a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@eeacms/volto-call-to-action-block",
-  "version": "4.2.1",
+  "version": "4.2.2",
   "description": "@eeacms/volto-call-to-action-block: Volto add-on",
   "main": "src/index.js",
   "author": "European Environment Agency: IDM2 A-Team",