From 28eb4972c1375fdb79044a1b8024b086a49c5702 Mon Sep 17 00:00:00 2001 From: fmadjdian Date: Wed, 28 May 2025 11:33:35 +0200 Subject: [PATCH 1/8] Added CICD files for automated deploys Also added inline comments to the files to make it more readable. --- Jenkinsfile-OTA | 122 +++++++++++++++++++++++++++++ Jenkinsfile-PullRequestChecker | 56 ++++++++++++++ Jenkinsfile-QA | 136 +++++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 Jenkinsfile-OTA create mode 100644 Jenkinsfile-PullRequestChecker create mode 100644 Jenkinsfile-QA diff --git a/Jenkinsfile-OTA b/Jenkinsfile-OTA new file mode 100644 index 0000000..cb81ced --- /dev/null +++ b/Jenkinsfile-OTA @@ -0,0 +1,122 @@ +// Define shared constants for the pipeline +def PIPELINE_AGENT_LABEL = 'Build-Medium' // Jenkins agent label +def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' // Docker image for Maven build +def CICD_LAST_STARTED_STAGE = '' // Track the last started stage + +pipeline { + agent { + label PIPELINE_AGENT_LABEL // Use the defined agent for the entire pipeline + } + + environment { + // Normalize job name + JOB_NAME_CLEAN = env.JOB_BASE_NAME.toLowerCase() + + // Generate a unique build name using an external script + GENERATED_BUILD_NAME = sh(script: "${CICD_SCRIPTS_DIR}/job/get_build_name.sh", returnStdout: true) + + // Load Docker registry credentials and configuration and image tag using external scripts + AERIUS_REGISTRY_HOSTNAME = credentials('DOCKER_REGISTRY_HOSTNAME') + AERIUS_REGISTRY_PATH = sh(script: "${CICD_SCRIPTS_DIR}/docker/get_registry_path.sh", returnStdout: true) + AERIUS_REGISTRY_URL = "${env.AERIUS_REGISTRY_HOSTNAME}/${env.AERIUS_REGISTRY_PATH}/" + AERIUS_IMAGE_TAG = sh(script: "${CICD_SCRIPTS_DIR}/docker/get_image_tag.sh", returnStdout: true) + + } + + stages { + stage('Init') { + steps { + // Set the display name of the build in Jenkins UI + buildName GENERATED_BUILD_NAME + } + } + + stage('Maven') { + agent { + docker { + label PIPELINE_AGENT_LABEL + image DOCKER_MAVEN_IMAGE + reuseNode true + } + } + steps { + script { CICD_LAST_STARTED_STAGE = STAGE_NAME } + + // Compile the Java project and package it + sh ''' + mvn -f source/pom.xml clean versions:set -DnewVersion="${AERIUS_IMAGE_TAG}" -Pdeploy --no-transfer-progress + mvn -f source/pom.xml clean package -Pdeploy -DskipTests -DfailIfNoTests=true --no-transfer-progress + ''' + } + } + + stage('Docker Images') { + environment { + + // Credentials for downloading additional Docker data + HTTPS_DATA_USERNAME = credentials('HTTPS_DBDATA_USERNAME') + HTTPS_DATA_PASSWORD = credentials('HTTPS_DBDATA_PASSWORD') + } + + steps { + script { CICD_LAST_STARTED_STAGE = STAGE_NAME } + sh ''' + cd docker + + # Prepare step - generate Dockerfiles/copy over assets + ./prepare.sh + + # Run CICD-script to do extra work if needed for the images + "${CICD_SCRIPTS_DIR}"/docker/prescript_v1.0.sh + + # Build + ./build.sh + + # Push images + ./push.sh + ''' + } + } + + stage('Post job') { + environment { + + // Credentials for deployment + DEPLOY_OTA_ENVIRONMENT_CICD_URL = credentials('DEPLOY_OTA_ENVIRONMENT_CICD_URL') + DEPLOY_OTA_ENVIRONMENT_CICD_LOGIN = credentials('DEPLOY_OTA_ENVIRONMENT_CICD_LOGIN') + + // Build flags including any job-specific flags + FLAGS = "FAME-DEV/API,DOCS_BASE_URL_GRIP-DOCS-DEV,${env.JOB_SPECIFIC_FLAGS ?: ''}" + + // Generate build duration message for reporting + CICD_JOB_MESSAGES = sh(script: """${CICD_SCRIPTS_DIR}/job/add_job_duration.sh build "${currentBuild.durationString}" """, returnStdout: true) + } + + steps { + script { CICD_LAST_STARTED_STAGE = STAGE_NAME } + sh ''' + "${CICD_SCRIPTS_DIR}"/job/postscript_v1.0.sh + ''' + } + } + } + + post { + always { + withBuildUser { + script { + + // On failure send a Mattermost notification with details + if (currentBuild.result != 'SUCCESS') { + env.CICD_LAST_STARTED_STAGE = CICD_LAST_STARTED_STAGE + mattermostSend( + channel: (env.MATTERMOST_CHANNEL ? "#${env.MATTERMOST_CHANNEL}" : null), + color: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_color.sh "${currentBuild.result}" """, returnStdout: true), + message: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_message.sh "${currentBuild.result}" "${currentBuild.durationString}" build """, returnStdout: true) + ) + } + } + } + } + } +} diff --git a/Jenkinsfile-PullRequestChecker b/Jenkinsfile-PullRequestChecker new file mode 100644 index 0000000..7610230 --- /dev/null +++ b/Jenkinsfile-PullRequestChecker @@ -0,0 +1,56 @@ +// Define shared constants for the pipeline +def PIPELINE_AGENT_LABEL = 'PullRequestChecker' // Jenkins agent label +def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' // Docker image for Maven build + +pipeline { + agent { + label PIPELINE_AGENT_LABEL // Use the defined agent for the entire pipeline + } + + stages { + + stage('Build Maven') { + agent { + docker { + label PIPELINE_AGENT_LABEL + image DOCKER_MAVEN_IMAGE + reuseNode true + } + } + + steps { + // Provide the SonarQube authentication token from Jenkins credentials + withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { + + // Run Maven build with SonarQube analysis for a pull request + sh ''' + mvn -f source/pom.xml clean verify \ + org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ + -Pdeploy,sonar \ + --no-transfer-progress \ + -Dsonar.java.binaries=target \ + -Dsonar.pullrequest.key=${CHANGE_ID} \ // PR number + -Dsonar.pullrequest.branch=PR-${CHANGE_ID} \ // Temporary branch name + -Dsonar.pullrequest.base=${CHANGE_TARGET} // Target branch of the PR + ''' + } + } + } + + stage('Build Docker') { + steps { + + // Build Docker images with a profile tailored for PR checks + sh ''' + cd docker + + # Prepare Docker build context using a specific profile for pull requests + PROFILE=pullrequestchecker ./prepare.sh + + # Build the Docker image + ./build.sh + ''' + } + } + } +} diff --git a/Jenkinsfile-QA b/Jenkinsfile-QA new file mode 100644 index 0000000..ef97f60 --- /dev/null +++ b/Jenkinsfile-QA @@ -0,0 +1,136 @@ +// Define shared constants for the pipeline +def PIPELINE_AGENT_LABEL = 'QA' // Jenkins agent label +def DOCKER_CYPRESS_IMAGE = 'cypress/included:13.1.0' // Docker image with Cypress pre-installed +def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' // Docker image for Maven build +def CICD_LAST_STARTED_STAGE = '' // Track the last started stage + +pipeline { + agent { + label PIPELINE_AGENT_LABEL // Use the defined agent for the entire pipeline + } + + environment { + // Generate a temporary filename to store flag settings as a shell script + FLAG_SETTINGS_SCRIPT = sh(script: 'mktemp -u -p . tmp.XXXXXX.envsh', returnStdout: true) + + // Define feature flags + FLAGS = "CYPRESS_LOGIN_NL-DEV,${env.FLAGS ?: ''}" + TZ = 'Europe/Amsterdam' + } + + stages { + + stage('Init') { + steps { + // Update the last started stage name + script { CICD_LAST_STARTED_STAGE = STAGE_NAME } + + // Use SSH credentials to pull scripts or data if needed + sshagent(credentials: ['stikstofje-Github-SSH-key']) { + sh ''' + # Load flags into the shell environment + PRODUCT_NAME='GRIP' source "${CICD_SCRIPTS_DIR}"/common/read_job_flags.envsh + + # Save the loaded flags to a shell script file for later sourcing + declare -p FLAG_SETTINGS > "${FLAG_SETTINGS_SCRIPT}" + ''' + } + } + } + + stage('Cypress') { + agent { + docker { + label PIPELINE_AGENT_LABEL + image DOCKER_CYPRESS_IMAGE + reuseNode true + + // Mount CICD script directory into the container, override entrypoint + args "--entrypoint='' -v '${env.CICD_SCRIPTS_DIR}':'${env.CICD_SCRIPTS_DIR}' -e CICD_SCRIPTS_DIR='${env.CICD_SCRIPTS_DIR}'" + } + } + + steps { + script { CICD_LAST_STARTED_STAGE = STAGE_NAME } + sh '''#!/usr/bin/env bash + # Exit on error + print commands + set -ex + + # Read in flags from file + source "${FLAG_SETTINGS_SCRIPT}" + + # Change to working directory + cd source/frontend/ + + # Fetch npm modules + npm ci + + # Determine DEPLOY_WEBHOST related vars - this will have the URL the environment is deployed to + source "${CICD_SCRIPTS_DIR}"/common/determine_deploy_webhost.envsh + + # Wait on application to start properly + npx wait-on -l https://"${DEPLOY_WEBHOST}" + + # Wait extra time to ensure the environment is fully ready + sleep 30m + + # Start Cypress + CYPRESS_USERNAME="${FLAG_SETTINGS[CYPRESS_LOGIN_USERNAME]}" \ + CYPRESS_PASSWORD="${FLAG_SETTINGS[CYPRESS_LOGIN_PASSWORD]}" \ + CYPRESS_API_ENDPOINT="https://${FLAG_SETTINGS[FAME_PLATFORM_HOST]}" \ + CYPRESS_TEST_PROFILE="${SERVICE_THEME}" \ + cypress run \ + --config baseUrl=https://"${DEPLOY_WEBHOST}" \ + --config-file cypress/cypress.config.ts || true + ''' + } + } + + stage('Sonar') { + agent { + docker { + label PIPELINE_AGENT_LABEL + image DOCKER_MAVEN_IMAGE + reuseNode true + } + } + + steps { + script { CICD_LAST_STARTED_STAGE = STAGE_NAME } + + // Use SonarQube token from Jenkins credentials + withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { + sh 'mvn -f source/pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Psonar --no-transfer-progress -Dmaven.test.failure.ignore=true' + } + } + } + } + + post { + always { + + // Attempt to parse and archive any JUnit test results + catchError { + junit '**/TEST-*.xml,source/frontend/cypress/reports/junit/*.xml' + } + + // Attempt to parse and archive Cucumber reports generated by Cypress + catchError { + cucumber jsonReportDirectory: 'source/frontend/cypress/', fileIncludePattern: '**/*.cucumber.json' + } + + // Send build notification to Mattermost + withBuildUser { + script { + env.CICD_LAST_STARTED_STAGE = CICD_LAST_STARTED_STAGE + + mattermostSend( + channel: (env.MATTERMOST_CHANNEL ? "#${env.MATTERMOST_CHANNEL}" : null), + color: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_color.sh "${currentBuild.result}" """, returnStdout: true), + message: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_message.sh "${currentBuild.result}" "${currentBuild.durationString}" QA """, returnStdout: true) + ) + } + } + } + } +} From 8ed50ed133e4f68a83349284e836bc47773dc609 Mon Sep 17 00:00:00 2001 From: fmadjdian Date: Mon, 2 Jun 2025 10:35:53 +0200 Subject: [PATCH 2/8] Updated CICD files Updated the CICD files to remove comments not needed. One thing we need to discuss; do we want the PRODUCT_NAME to be CAPS or no caps. Only one product has CAPS in the flags target location, the rest is non-capitalized. --- Jenkinsfile-OTA | 28 ++----- Jenkinsfile-PullRequestChecker | 28 +------ Jenkinsfile-QA | 59 ++++++-------- search-sonar-report/pom.xml.versionsBackup | 92 ++++++++++++++++++++++ 4 files changed, 123 insertions(+), 84 deletions(-) create mode 100644 search-sonar-report/pom.xml.versionsBackup diff --git a/Jenkinsfile-OTA b/Jenkinsfile-OTA index cb81ced..466360d 100644 --- a/Jenkinsfile-OTA +++ b/Jenkinsfile-OTA @@ -1,21 +1,16 @@ -// Define shared constants for the pipeline -def PIPELINE_AGENT_LABEL = 'Build-Medium' // Jenkins agent label -def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' // Docker image for Maven build -def CICD_LAST_STARTED_STAGE = '' // Track the last started stage +def PIPELINE_AGENT_LABEL = 'Build-Medium' +def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' +def CICD_LAST_STARTED_STAGE = '' pipeline { agent { - label PIPELINE_AGENT_LABEL // Use the defined agent for the entire pipeline + label PIPELINE_AGENT_LABEL } environment { - // Normalize job name JOB_NAME_CLEAN = env.JOB_BASE_NAME.toLowerCase() - - // Generate a unique build name using an external script GENERATED_BUILD_NAME = sh(script: "${CICD_SCRIPTS_DIR}/job/get_build_name.sh", returnStdout: true) - // Load Docker registry credentials and configuration and image tag using external scripts AERIUS_REGISTRY_HOSTNAME = credentials('DOCKER_REGISTRY_HOSTNAME') AERIUS_REGISTRY_PATH = sh(script: "${CICD_SCRIPTS_DIR}/docker/get_registry_path.sh", returnStdout: true) AERIUS_REGISTRY_URL = "${env.AERIUS_REGISTRY_HOSTNAME}/${env.AERIUS_REGISTRY_PATH}/" @@ -26,7 +21,6 @@ pipeline { stages { stage('Init') { steps { - // Set the display name of the build in Jenkins UI buildName GENERATED_BUILD_NAME } } @@ -41,8 +35,6 @@ pipeline { } steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } - - // Compile the Java project and package it sh ''' mvn -f source/pom.xml clean versions:set -DnewVersion="${AERIUS_IMAGE_TAG}" -Pdeploy --no-transfer-progress mvn -f source/pom.xml clean package -Pdeploy -DskipTests -DfailIfNoTests=true --no-transfer-progress @@ -52,8 +44,6 @@ pipeline { stage('Docker Images') { environment { - - // Credentials for downloading additional Docker data HTTPS_DATA_USERNAME = credentials('HTTPS_DBDATA_USERNAME') HTTPS_DATA_PASSWORD = credentials('HTTPS_DBDATA_PASSWORD') } @@ -80,15 +70,9 @@ pipeline { stage('Post job') { environment { - - // Credentials for deployment DEPLOY_OTA_ENVIRONMENT_CICD_URL = credentials('DEPLOY_OTA_ENVIRONMENT_CICD_URL') DEPLOY_OTA_ENVIRONMENT_CICD_LOGIN = credentials('DEPLOY_OTA_ENVIRONMENT_CICD_LOGIN') - - // Build flags including any job-specific flags - FLAGS = "FAME-DEV/API,DOCS_BASE_URL_GRIP-DOCS-DEV,${env.JOB_SPECIFIC_FLAGS ?: ''}" - - // Generate build duration message for reporting + FLAGS = "${env.JOB_SPECIFIC_FLAGS ?: ''}" CICD_JOB_MESSAGES = sh(script: """${CICD_SCRIPTS_DIR}/job/add_job_duration.sh build "${currentBuild.durationString}" """, returnStdout: true) } @@ -105,8 +89,6 @@ pipeline { always { withBuildUser { script { - - // On failure send a Mattermost notification with details if (currentBuild.result != 'SUCCESS') { env.CICD_LAST_STARTED_STAGE = CICD_LAST_STARTED_STAGE mattermostSend( diff --git a/Jenkinsfile-PullRequestChecker b/Jenkinsfile-PullRequestChecker index 7610230..422200f 100644 --- a/Jenkinsfile-PullRequestChecker +++ b/Jenkinsfile-PullRequestChecker @@ -1,14 +1,12 @@ -// Define shared constants for the pipeline -def PIPELINE_AGENT_LABEL = 'PullRequestChecker' // Jenkins agent label -def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' // Docker image for Maven build +def PIPELINE_AGENT_LABEL = 'PullRequestChecker' +def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' pipeline { agent { - label PIPELINE_AGENT_LABEL // Use the defined agent for the entire pipeline + label PIPELINE_AGENT_LABEL } stages { - stage('Build Maven') { agent { docker { @@ -19,35 +17,17 @@ pipeline { } steps { - // Provide the SonarQube authentication token from Jenkins credentials withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { - - // Run Maven build with SonarQube analysis for a pull request - sh ''' - mvn -f source/pom.xml clean verify \ - org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ - -Pdeploy,sonar \ - --no-transfer-progress \ - -Dsonar.java.binaries=target \ - -Dsonar.pullrequest.key=${CHANGE_ID} \ // PR number - -Dsonar.pullrequest.branch=PR-${CHANGE_ID} \ // Temporary branch name - -Dsonar.pullrequest.base=${CHANGE_TARGET} // Target branch of the PR - ''' + sh 'mvn -f source/pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Pdeploy,sonar --no-transfer-progress -Dsonar.java.binaries=target -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.pullrequest.branch=PR-${CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET}' } } } stage('Build Docker') { steps { - - // Build Docker images with a profile tailored for PR checks sh ''' cd docker - - # Prepare Docker build context using a specific profile for pull requests PROFILE=pullrequestchecker ./prepare.sh - - # Build the Docker image ./build.sh ''' } diff --git a/Jenkinsfile-QA b/Jenkinsfile-QA index ef97f60..458aa46 100644 --- a/Jenkinsfile-QA +++ b/Jenkinsfile-QA @@ -1,37 +1,30 @@ -// Define shared constants for the pipeline -def PIPELINE_AGENT_LABEL = 'QA' // Jenkins agent label -def DOCKER_CYPRESS_IMAGE = 'cypress/included:13.1.0' // Docker image with Cypress pre-installed -def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' // Docker image for Maven build -def CICD_LAST_STARTED_STAGE = '' // Track the last started stage +def PIPELINE_AGENT_LABEL = 'QA' +def DOCKER_CYPRESS_IMAGE = 'cypress/included:13.1.0' +def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' +def CICD_LAST_STARTED_STAGE = '' pipeline { agent { - label PIPELINE_AGENT_LABEL // Use the defined agent for the entire pipeline + label PIPELINE_AGENT_LABEL } environment { - // Generate a temporary filename to store flag settings as a shell script FLAG_SETTINGS_SCRIPT = sh(script: 'mktemp -u -p . tmp.XXXXXX.envsh', returnStdout: true) + FLAGS = "CYPRESS_LOGIN_NL-DEV,${env.FLAGS ?: ''}" + TZ = 'Europe/Amsterdam' - // Define feature flags - FLAGS = "CYPRESS_LOGIN_NL-DEV,${env.FLAGS ?: ''}" - TZ = 'Europe/Amsterdam' } stages { - stage('Init') { steps { - // Update the last started stage name script { CICD_LAST_STARTED_STAGE = STAGE_NAME } - - // Use SSH credentials to pull scripts or data if needed sshagent(credentials: ['stikstofje-Github-SSH-key']) { sh ''' - # Load flags into the shell environment - PRODUCT_NAME='GRIP' source "${CICD_SCRIPTS_DIR}"/common/read_job_flags.envsh + # Read job flags + PRODUCT_NAME='search' source "${CICD_SCRIPTS_DIR}"/common/read_job_flags.envsh - # Save the loaded flags to a shell script file for later sourcing + # Export flags to file declare -p FLAG_SETTINGS > "${FLAG_SETTINGS_SCRIPT}" ''' } @@ -43,16 +36,18 @@ pipeline { docker { label PIPELINE_AGENT_LABEL image DOCKER_CYPRESS_IMAGE - reuseNode true - - // Mount CICD script directory into the container, override entrypoint + // Reset entrypoint so we can execute our own script + // Add volume to the cicd-scripts + // Also pass CICD_SCRIPTS_DIR args "--entrypoint='' -v '${env.CICD_SCRIPTS_DIR}':'${env.CICD_SCRIPTS_DIR}' -e CICD_SCRIPTS_DIR='${env.CICD_SCRIPTS_DIR}'" + reuseNode true } } steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } sh '''#!/usr/bin/env bash + # Exit on error + print commands set -ex @@ -71,7 +66,7 @@ pipeline { # Wait on application to start properly npx wait-on -l https://"${DEPLOY_WEBHOST}" - # Wait extra time to ensure the environment is fully ready + # Wait some extra to start properly sleep 30m # Start Cypress @@ -97,8 +92,6 @@ pipeline { steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } - - // Use SonarQube token from Jenkins credentials withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { sh 'mvn -f source/pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Psonar --no-transfer-progress -Dmaven.test.failure.ignore=true' } @@ -108,28 +101,20 @@ pipeline { post { always { - - // Attempt to parse and archive any JUnit test results catchError { junit '**/TEST-*.xml,source/frontend/cypress/reports/junit/*.xml' } - - // Attempt to parse and archive Cucumber reports generated by Cypress catchError { cucumber jsonReportDirectory: 'source/frontend/cypress/', fileIncludePattern: '**/*.cucumber.json' } - // Send build notification to Mattermost withBuildUser { - script { - env.CICD_LAST_STARTED_STAGE = CICD_LAST_STARTED_STAGE - - mattermostSend( - channel: (env.MATTERMOST_CHANNEL ? "#${env.MATTERMOST_CHANNEL}" : null), - color: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_color.sh "${currentBuild.result}" """, returnStdout: true), - message: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_message.sh "${currentBuild.result}" "${currentBuild.durationString}" QA """, returnStdout: true) - ) - } + script { env.CICD_LAST_STARTED_STAGE = CICD_LAST_STARTED_STAGE } + mattermostSend( + channel: (env.MATTERMOST_CHANNEL ? "#${env.MATTERMOST_CHANNEL}" : null), + color: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_color.sh "${currentBuild.result}" """, returnStdout: true), + message: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_message.sh "${currentBuild.result}" "${currentBuild.durationString}" QA """, returnStdout: true) + ) } } } diff --git a/search-sonar-report/pom.xml.versionsBackup b/search-sonar-report/pom.xml.versionsBackup new file mode 100644 index 0000000..7557f27 --- /dev/null +++ b/search-sonar-report/pom.xml.versionsBackup @@ -0,0 +1,92 @@ + + + 4.0.0 + + nl.aerius + search-parent + 1.8.0-SNAPSHOT + + + search-sonar-report + + AERIUS Search :: Sonar Report + AERIUS Search SonarQube Jacoco module to collect Coverage reports + + + + nl.aerius + search-service + ${project.version} + + + nl.aerius + search-service-bing-geocoder + ${project.version} + + + nl.aerius + search-service-extension + ${project.version} + + + nl.aerius + search-service-geo + ${project.version} + + + nl.aerius + search-service-mocks + ${project.version} + + + nl.aerius + search-service-n2000-assessment-areas-nl + ${project.version} + + + nl.aerius + search-service-pdok-locatieservice + ${project.version} + + + nl.aerius + search-shared + ${project.version} + + + + + + + org.jacoco + jacoco-maven-plugin + + + report + + report-aggregate + + verify + + + + + + From 129f5ac88d4a342dde57bb236c390506a8374706 Mon Sep 17 00:00:00 2001 From: fmadjdian Date: Thu, 5 Jun 2025 11:01:38 +0200 Subject: [PATCH 3/8] Remove unneeded file Was accidentally included. --- search-sonar-report/pom.xml.versionsBackup | 92 ---------------------- 1 file changed, 92 deletions(-) delete mode 100644 search-sonar-report/pom.xml.versionsBackup diff --git a/search-sonar-report/pom.xml.versionsBackup b/search-sonar-report/pom.xml.versionsBackup deleted file mode 100644 index 7557f27..0000000 --- a/search-sonar-report/pom.xml.versionsBackup +++ /dev/null @@ -1,92 +0,0 @@ - - - 4.0.0 - - nl.aerius - search-parent - 1.8.0-SNAPSHOT - - - search-sonar-report - - AERIUS Search :: Sonar Report - AERIUS Search SonarQube Jacoco module to collect Coverage reports - - - - nl.aerius - search-service - ${project.version} - - - nl.aerius - search-service-bing-geocoder - ${project.version} - - - nl.aerius - search-service-extension - ${project.version} - - - nl.aerius - search-service-geo - ${project.version} - - - nl.aerius - search-service-mocks - ${project.version} - - - nl.aerius - search-service-n2000-assessment-areas-nl - ${project.version} - - - nl.aerius - search-service-pdok-locatieservice - ${project.version} - - - nl.aerius - search-shared - ${project.version} - - - - - - - org.jacoco - jacoco-maven-plugin - - - report - - report-aggregate - - verify - - - - - - From d494d023bd91ca2443a1a0f2d34b5969aff17f38 Mon Sep 17 00:00:00 2001 From: fmadjdian Date: Thu, 5 Jun 2025 11:33:33 +0200 Subject: [PATCH 4/8] Updates to files and removed QA Updated OTA file to use external script directory for image build. Removed QA file, will not be used for now. --- Jenkinsfile-OTA | 19 +----- Jenkinsfile-PullRequestChecker | 3 +- Jenkinsfile-QA | 121 --------------------------------- docker/build.sh | 12 ---- docker/prepare.sh | 11 --- 5 files changed, 4 insertions(+), 162 deletions(-) delete mode 100644 Jenkinsfile-QA delete mode 100755 docker/build.sh delete mode 100755 docker/prepare.sh diff --git a/Jenkinsfile-OTA b/Jenkinsfile-OTA index 466360d..0a69d9d 100644 --- a/Jenkinsfile-OTA +++ b/Jenkinsfile-OTA @@ -43,27 +43,14 @@ pipeline { } stage('Docker Images') { - environment { - HTTPS_DATA_USERNAME = credentials('HTTPS_DBDATA_USERNAME') - HTTPS_DATA_PASSWORD = credentials('HTTPS_DBDATA_PASSWORD') - } steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } sh ''' - cd docker - - # Prepare step - generate Dockerfiles/copy over assets - ./prepare.sh + export AERIUS_GITHASH="$(git log -1 --pretty=format:%h)" - # Run CICD-script to do extra work if needed for the images - "${CICD_SCRIPTS_DIR}"/docker/prescript_v1.0.sh - - # Build - ./build.sh - - # Push images - ./push.sh + cd docker + "${CICD_SCRIPTS_DIR}"/docker/images_v1.0.sh ''' } } diff --git a/Jenkinsfile-PullRequestChecker b/Jenkinsfile-PullRequestChecker index 422200f..f2dea63 100644 --- a/Jenkinsfile-PullRequestChecker +++ b/Jenkinsfile-PullRequestChecker @@ -27,8 +27,7 @@ pipeline { steps { sh ''' cd docker - PROFILE=pullrequestchecker ./prepare.sh - ./build.sh + PROFILE=pullrequestchecker "${CICD_SCRIPTS_DIR}"/docker/images_v1.0.sh --no-push ''' } } diff --git a/Jenkinsfile-QA b/Jenkinsfile-QA deleted file mode 100644 index 458aa46..0000000 --- a/Jenkinsfile-QA +++ /dev/null @@ -1,121 +0,0 @@ -def PIPELINE_AGENT_LABEL = 'QA' -def DOCKER_CYPRESS_IMAGE = 'cypress/included:13.1.0' -def DOCKER_MAVEN_IMAGE = 'maven:3-eclipse-temurin-21' -def CICD_LAST_STARTED_STAGE = '' - -pipeline { - agent { - label PIPELINE_AGENT_LABEL - } - - environment { - FLAG_SETTINGS_SCRIPT = sh(script: 'mktemp -u -p . tmp.XXXXXX.envsh', returnStdout: true) - FLAGS = "CYPRESS_LOGIN_NL-DEV,${env.FLAGS ?: ''}" - TZ = 'Europe/Amsterdam' - - } - - stages { - stage('Init') { - steps { - script { CICD_LAST_STARTED_STAGE = STAGE_NAME } - sshagent(credentials: ['stikstofje-Github-SSH-key']) { - sh ''' - # Read job flags - PRODUCT_NAME='search' source "${CICD_SCRIPTS_DIR}"/common/read_job_flags.envsh - - # Export flags to file - declare -p FLAG_SETTINGS > "${FLAG_SETTINGS_SCRIPT}" - ''' - } - } - } - - stage('Cypress') { - agent { - docker { - label PIPELINE_AGENT_LABEL - image DOCKER_CYPRESS_IMAGE - // Reset entrypoint so we can execute our own script - // Add volume to the cicd-scripts - // Also pass CICD_SCRIPTS_DIR - args "--entrypoint='' -v '${env.CICD_SCRIPTS_DIR}':'${env.CICD_SCRIPTS_DIR}' -e CICD_SCRIPTS_DIR='${env.CICD_SCRIPTS_DIR}'" - reuseNode true - } - } - - steps { - script { CICD_LAST_STARTED_STAGE = STAGE_NAME } - sh '''#!/usr/bin/env bash - - # Exit on error + print commands - set -ex - - # Read in flags from file - source "${FLAG_SETTINGS_SCRIPT}" - - # Change to working directory - cd source/frontend/ - - # Fetch npm modules - npm ci - - # Determine DEPLOY_WEBHOST related vars - this will have the URL the environment is deployed to - source "${CICD_SCRIPTS_DIR}"/common/determine_deploy_webhost.envsh - - # Wait on application to start properly - npx wait-on -l https://"${DEPLOY_WEBHOST}" - - # Wait some extra to start properly - sleep 30m - - # Start Cypress - CYPRESS_USERNAME="${FLAG_SETTINGS[CYPRESS_LOGIN_USERNAME]}" \ - CYPRESS_PASSWORD="${FLAG_SETTINGS[CYPRESS_LOGIN_PASSWORD]}" \ - CYPRESS_API_ENDPOINT="https://${FLAG_SETTINGS[FAME_PLATFORM_HOST]}" \ - CYPRESS_TEST_PROFILE="${SERVICE_THEME}" \ - cypress run \ - --config baseUrl=https://"${DEPLOY_WEBHOST}" \ - --config-file cypress/cypress.config.ts || true - ''' - } - } - - stage('Sonar') { - agent { - docker { - label PIPELINE_AGENT_LABEL - image DOCKER_MAVEN_IMAGE - reuseNode true - } - } - - steps { - script { CICD_LAST_STARTED_STAGE = STAGE_NAME } - withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { - sh 'mvn -f source/pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Psonar --no-transfer-progress -Dmaven.test.failure.ignore=true' - } - } - } - } - - post { - always { - catchError { - junit '**/TEST-*.xml,source/frontend/cypress/reports/junit/*.xml' - } - catchError { - cucumber jsonReportDirectory: 'source/frontend/cypress/', fileIncludePattern: '**/*.cucumber.json' - } - - withBuildUser { - script { env.CICD_LAST_STARTED_STAGE = CICD_LAST_STARTED_STAGE } - mattermostSend( - channel: (env.MATTERMOST_CHANNEL ? "#${env.MATTERMOST_CHANNEL}" : null), - color: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_color.sh "${currentBuild.result}" """, returnStdout: true), - message: sh(script: """${CICD_SCRIPTS_DIR}/job/notify_mattermost_message.sh "${currentBuild.result}" "${currentBuild.durationString}" QA """, returnStdout: true) - ) - } - } - } -} diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 1655278..0000000 --- a/docker/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# Exit on error -set -e - -# Change current directory to directory of script so it can be called from everywhere -SCRIPT_PATH=$(readlink -f "${0}") -SCRIPT_DIR=$(dirname "${SCRIPT_PATH}") -cd "${SCRIPT_DIR}" - -# Build like we are in the root directory -docker-compose --project-directory ../ --env-file docker/.env build diff --git a/docker/prepare.sh b/docker/prepare.sh deleted file mode 100755 index a2e6981..0000000 --- a/docker/prepare.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# Exit on error -set -e - -# Change current directory to directory of script so it can be called from everywhere -SCRIPT_PATH=$(readlink -f "${0}") -SCRIPT_DIR=$(dirname "${SCRIPT_PATH}") -cd "${SCRIPT_DIR}" - -# For now does nothing - placeholder From a5c384fd4acbfca9092e5bd9918dd482eb95fba6 Mon Sep 17 00:00:00 2001 From: fmadjdian Date: Thu, 5 Jun 2025 11:51:38 +0200 Subject: [PATCH 5/8] Moved the location of pom.xml pom.xml for this project is not in the source folder. Adjusted the files. --- Jenkinsfile-OTA | 6 ++---- Jenkinsfile-PullRequestChecker | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile-OTA b/Jenkinsfile-OTA index 0a69d9d..77b73e1 100644 --- a/Jenkinsfile-OTA +++ b/Jenkinsfile-OTA @@ -36,8 +36,8 @@ pipeline { steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } sh ''' - mvn -f source/pom.xml clean versions:set -DnewVersion="${AERIUS_IMAGE_TAG}" -Pdeploy --no-transfer-progress - mvn -f source/pom.xml clean package -Pdeploy -DskipTests -DfailIfNoTests=true --no-transfer-progress + mvn -f pom.xml clean versions:set -DnewVersion="${AERIUS_IMAGE_TAG}" -Pdeploy --no-transfer-progress + mvn -f pom.xml clean package -Pdeploy -DskipTests -DfailIfNoTests=true --no-transfer-progress ''' } } @@ -47,8 +47,6 @@ pipeline { steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } sh ''' - export AERIUS_GITHASH="$(git log -1 --pretty=format:%h)" - cd docker "${CICD_SCRIPTS_DIR}"/docker/images_v1.0.sh ''' diff --git a/Jenkinsfile-PullRequestChecker b/Jenkinsfile-PullRequestChecker index f2dea63..b6eea19 100644 --- a/Jenkinsfile-PullRequestChecker +++ b/Jenkinsfile-PullRequestChecker @@ -18,7 +18,7 @@ pipeline { steps { withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { - sh 'mvn -f source/pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Pdeploy,sonar --no-transfer-progress -Dsonar.java.binaries=target -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.pullrequest.branch=PR-${CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET}' + sh 'mvn -f pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Pdeploy,sonar --no-transfer-progress -Dsonar.java.binaries=target -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.pullrequest.branch=PR-${CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET}' } } } From f81992a8a0e5a1514c8593a05fe22ce0e730cb67 Mon Sep 17 00:00:00 2001 From: fmadjdian <62754927+fmadjdian@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:51:36 +0200 Subject: [PATCH 6/8] Update Jenkinsfile-OTA Co-authored-by: Serhat --- Jenkinsfile-OTA | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile-OTA b/Jenkinsfile-OTA index 77b73e1..431bd62 100644 --- a/Jenkinsfile-OTA +++ b/Jenkinsfile-OTA @@ -36,8 +36,8 @@ pipeline { steps { script { CICD_LAST_STARTED_STAGE = STAGE_NAME } sh ''' - mvn -f pom.xml clean versions:set -DnewVersion="${AERIUS_IMAGE_TAG}" -Pdeploy --no-transfer-progress - mvn -f pom.xml clean package -Pdeploy -DskipTests -DfailIfNoTests=true --no-transfer-progress + mvn clean versions:set -DnewVersion="${AERIUS_IMAGE_TAG}" -Pdeploy --no-transfer-progress + mvn clean package -Pdeploy -DskipTests -DfailIfNoTests=true --no-transfer-progress ''' } } From 0a9436b88db742eff2c3c02ada835d520ccf773d Mon Sep 17 00:00:00 2001 From: fmadjdian <62754927+fmadjdian@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:51:49 +0200 Subject: [PATCH 7/8] Update Jenkinsfile-PullRequestChecker Co-authored-by: Serhat --- Jenkinsfile-PullRequestChecker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-PullRequestChecker b/Jenkinsfile-PullRequestChecker index b6eea19..cd6b373 100644 --- a/Jenkinsfile-PullRequestChecker +++ b/Jenkinsfile-PullRequestChecker @@ -18,7 +18,7 @@ pipeline { steps { withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) { - sh 'mvn -f pom.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Pdeploy,sonar --no-transfer-progress -Dsonar.java.binaries=target -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.pullrequest.branch=PR-${CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET}' + sh 'mvn clean verify org.sonarsource.scanner.maven:sonar-maven-plugin::sonar -Pdeploy,sonar --no-transfer-progress -Dsonar.java.binaries=target -Dsonar.pullrequest.key=${CHANGE_ID} -Dsonar.pullrequest.branch=PR-${CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET}' } } } From 847ca89618819d3ff3496cf1b58fb6faa0c6a135 Mon Sep 17 00:00:00 2001 From: fmadjdian <62754927+fmadjdian@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:52:16 +0200 Subject: [PATCH 8/8] Update Jenkinsfile-PullRequestChecker Co-authored-by: Serhat --- Jenkinsfile-PullRequestChecker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-PullRequestChecker b/Jenkinsfile-PullRequestChecker index cd6b373..ee8931c 100644 --- a/Jenkinsfile-PullRequestChecker +++ b/Jenkinsfile-PullRequestChecker @@ -27,7 +27,7 @@ pipeline { steps { sh ''' cd docker - PROFILE=pullrequestchecker "${CICD_SCRIPTS_DIR}"/docker/images_v1.0.sh --no-push + "${CICD_SCRIPTS_DIR}"/docker/images_v1.0.sh --no-push ''' } }