From f2eb12625a0b16c6e53d055ee1ccc405e2262a1a Mon Sep 17 00:00:00 2001 From: greenboy106 Date: Wed, 28 May 2025 01:13:18 +1000 Subject: [PATCH 01/43] Add Jenkinsfile --- Jenkinsfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000000..c3ae18353b0 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,27 @@ +{\rtf1\ansi\ansicpg1252\cocoartf2822 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;} +{\*\expandedcolortbl;;} +\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 + +\f0\fs24 \cf0 pipeline \{\ + agent any\ + stages \{\ + stage('Checkout') \{\ + steps \{\ + git url: 'https://github.com/YOUR_USERNAME/8.2CDevSecOps.git'\ + \}\ + \}\ + stage('Build') \{\ + steps \{ sh 'npm install' \}\ + \}\ + stage('Test') \{\ + steps \{ sh 'npm test || true' \}\ + \}\ + stage('Security Scan') \{\ + steps \{ sh 'npm audit --audit-level=low || true' \}\ + \}\ + \}\ +\}\ +} \ No newline at end of file From 026c37a1884d07028df2d7ca9a8a096270997fef Mon Sep 17 00:00:00 2001 From: greenboy106 Date: Wed, 28 May 2025 01:35:03 +1000 Subject: [PATCH 02/43] Fix: correct GitHub URL in Jenkinsfile --- Jenkinsfile | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index c3ae18353b0..00000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,27 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf2822 -\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;} -{\colortbl;\red255\green255\blue255;} -{\*\expandedcolortbl;;} -\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 - -\f0\fs24 \cf0 pipeline \{\ - agent any\ - stages \{\ - stage('Checkout') \{\ - steps \{\ - git url: 'https://github.com/YOUR_USERNAME/8.2CDevSecOps.git'\ - \}\ - \}\ - stage('Build') \{\ - steps \{ sh 'npm install' \}\ - \}\ - stage('Test') \{\ - steps \{ sh 'npm test || true' \}\ - \}\ - stage('Security Scan') \{\ - steps \{ sh 'npm audit --audit-level=low || true' \}\ - \}\ - \}\ -\}\ -} \ No newline at end of file From 4259941cfeee0f546ee3ddade8d3e075f28568ed Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 02:12:56 +1000 Subject: [PATCH 03/43] Create Jenkinsfile --- Jenkinsfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000000..de3119dd844 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,31 @@ +pipeline { + agent any + stages { + stage('Checkout') { + steps { + git credentialsId: 'github-creds', url: 'https://github.com/greenboy106/8.2CDevSecOps.git' + } + } + stage('Build') { + steps { sh 'npm install' } + } + stage('Unit & Integration Tests') { + steps { sh 'npm test || true' } + } + stage('Static Code Analysis') { + steps { echo 'Skipping real analysis in this example' } + } + stage('Security Scan') { + steps { sh 'npm audit --audit-level=low || true' } + } + stage('Deploy to Staging') { + steps { echo 'Deploying to staging...' } + } + stage('Smoke Tests on Staging') { + steps { echo 'Running smoke tests...' } + } + stage('Deploy to Production') { + steps { echo 'Deploying to production...' } + } + } +} From c144963eb94257f3b8a641d3ed5d428f8a322945 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 02:48:00 +1000 Subject: [PATCH 04/43] Update Jenkinsfile --- Jenkinsfile | 79 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index de3119dd844..441f6b58c93 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,31 +1,54 @@ pipeline { - agent any - stages { - stage('Checkout') { - steps { - git credentialsId: 'github-creds', url: 'https://github.com/greenboy106/8.2CDevSecOps.git' - } + agent any + stages { + stage('Checkout') { + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/main']], + doGenerateSubmoduleConfigurations: false, + extensions: [], + userRemoteConfigs: [[ + url: 'https://github.com/greenboy106/8.2CDevSecOps.git', + credentialsId: 'github-creds' + ]] + ]) + } + } + stage('Build') { + steps { + sh 'npm install' + } + } + stage('Unit & Integration Tests') { + steps { + sh 'npm test || true' + } + } + stage('Static Code Analysis') { + steps { + echo 'Static analysis placeholder - add your tool here' + } + } + stage('Security Scan') { + steps { + sh 'npm audit --audit-level=low || true' + } + } + stage('Deploy to Staging') { + steps { + echo 'Deploying to staging environment...' + } + } + stage('Smoke Tests on Staging') { + steps { + echo 'Running smoke tests on staging...' + } + } + stage('Deploy to Production') { + steps { + echo 'Deploying to production environment...' + } + } } - stage('Build') { - steps { sh 'npm install' } - } - stage('Unit & Integration Tests') { - steps { sh 'npm test || true' } - } - stage('Static Code Analysis') { - steps { echo 'Skipping real analysis in this example' } - } - stage('Security Scan') { - steps { sh 'npm audit --audit-level=low || true' } - } - stage('Deploy to Staging') { - steps { echo 'Deploying to staging...' } - } - stage('Smoke Tests on Staging') { - steps { echo 'Running smoke tests...' } - } - stage('Deploy to Production') { - steps { echo 'Deploying to production...' } - } - } } From 362f7dd1d19cb50b5056a01636b6eb61fea95391 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 02:52:46 +1000 Subject: [PATCH 05/43] Update Jenkinsfile --- Jenkinsfile | 81 +++++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 52 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 441f6b58c93..bb9fbce2491 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,54 +1,31 @@ pipeline { - agent any - stages { - stage('Checkout') { - steps { - checkout([ - $class: 'GitSCM', - branches: [[name: '*/main']], - doGenerateSubmoduleConfigurations: false, - extensions: [], - userRemoteConfigs: [[ - url: 'https://github.com/greenboy106/8.2CDevSecOps.git', - credentialsId: 'github-creds' - ]] - ]) - } - } - stage('Build') { - steps { - sh 'npm install' - } - } - stage('Unit & Integration Tests') { - steps { - sh 'npm test || true' - } - } - stage('Static Code Analysis') { - steps { - echo 'Static analysis placeholder - add your tool here' - } - } - stage('Security Scan') { - steps { - sh 'npm audit --audit-level=low || true' - } - } - stage('Deploy to Staging') { - steps { - echo 'Deploying to staging environment...' - } - } - stage('Smoke Tests on Staging') { - steps { - echo 'Running smoke tests on staging...' - } - } - stage('Deploy to Production') { - steps { - echo 'Deploying to production environment...' - } - } - } + agent any + stages { + stage('Checkout') { + steps { + git branch: 'main', url: ' https://github.com/your_github_username/8.2CDevSecOps.git' + } + } + stage('Install Dependencies') { + steps { + sh 'npm install' + } + } + stage('Run Tests') { + steps { + sh 'npm test || true' // Allows pipeline to continue despite test failures + } + } + stage('Generate Coverage Report') { + steps { + // Ensure coverage report exists + sh 'npm run coverage || true' + } + } + stage('NPM Audit (Security Scan)') { + steps { + sh 'npm audit || true' // This will show known CVEs in the output + } + } + } } From f82888949f2c1494fd9522155fde77f97dcdf8e9 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 02:55:16 +1000 Subject: [PATCH 06/43] Update Jenkinsfile --- Jenkinsfile | 83 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bb9fbce2491..5c369fe8880 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,31 +1,56 @@ pipeline { - agent any - stages { - stage('Checkout') { - steps { - git branch: 'main', url: ' https://github.com/your_github_username/8.2CDevSecOps.git' - } - } - stage('Install Dependencies') { - steps { - sh 'npm install' - } - } - stage('Run Tests') { - steps { - sh 'npm test || true' // Allows pipeline to continue despite test failures - } - } - stage('Generate Coverage Report') { - steps { - // Ensure coverage report exists - sh 'npm run coverage || true' - } - } - stage('NPM Audit (Security Scan)') { - steps { - sh 'npm audit || true' // This will show known CVEs in the output - } - } - } + agent any + stages { + stage('Checkout') { + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/main']], + userRemoteConfigs: [[ + url: 'https://github.com/greenboy106/8.2CDevSecOps.git', + credentialsId: 'github-creds' + ]] + ]) + } + } + stage('Build') { + steps { + sh 'npm install' + } + } + stage('Unit & Integration Tests') { + steps { + // Runs tests; '|| true' ensures pipeline continues if tests fail + sh 'npm test || true' + } + } + stage('Static Code Analysis') { + steps { + echo 'Static analysis placeholder - add your tool here' + } + } + stage('Security Scan') { + steps { + sh 'npm audit --audit-level=low || true' + } + } + stage('Deploy to Staging') { + steps { + echo 'Deploying to staging environment...' + // Add your real deploy commands here + } + } + stage('Smoke Tests on Staging') { + steps { + echo 'Running smoke tests on staging...' + // Add real smoke test commands here + } + } + stage('Deploy to Production') { + steps { + echo 'Deploying to production environment...' + // Add your real deploy commands here + } + } + } } From ac4bd4d9c2d996e7b43126f492dc74980c1a9ce4 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 20:49:29 +1000 Subject: [PATCH 07/43] Create sonar-project.properties --- sonar-project.properties | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000000..d38c974f64f --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,11 @@ +sonar.projectKey=ee115110b80c114a6ebc7d66b5df433b24b0e57c +sonar.organization=greenboy106 +sonar.host.url=https://sonarcloud.io +sonar.login=${SONAR_TOKEN} + +sonar.sources=. +sonar.exclusions=node_modules/**,test/** +sonar.javascript.lcov.reportPaths=coverage/lcov.info + +sonar.projectName=NodeJS Goof Vulnerable App +sonar.sourceEncoding=UTF-8 From 9b18e4801bccca55339ca56182a6045923954265 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:01:14 +1000 Subject: [PATCH 08/43] Update Jenkinsfile --- Jenkinsfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5c369fe8880..56079efab1d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,5 +52,22 @@ pipeline { // Add your real deploy commands here } } + stage('SonarCloud Analysis') { + environment { + SONAR_TOKEN = credentials('SONAR_TOKEN') + } + steps { + sh ''' + # Download SonarScanner CLI (command-line tool) + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip + + # Unzip the downloaded file + unzip -o sonar-scanner-cli-4.8.0.2856-linux.zip + + # Run the SonarScanner CLI to analyze your code and send results to SonarCloud + ./sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner + ''' + } + } } } From 058143ac868c463370aadef111da03ad24d08de2 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:08:21 +1000 Subject: [PATCH 09/43] Update Jenkinsfile --- Jenkinsfile | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 56079efab1d..e80aef86630 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,6 @@ pipeline { } stage('Unit & Integration Tests') { steps { - // Runs tests; '|| true' ensures pipeline continues if tests fail sh 'npm test || true' } } @@ -37,36 +36,26 @@ pipeline { stage('Deploy to Staging') { steps { echo 'Deploying to staging environment...' - // Add your real deploy commands here } } stage('Smoke Tests on Staging') { steps { echo 'Running smoke tests on staging...' - // Add real smoke test commands here } } stage('Deploy to Production') { steps { echo 'Deploying to production environment...' - // Add your real deploy commands here } } stage('SonarCloud Analysis') { environment { SONAR_TOKEN = credentials('SONAR_TOKEN') - } - steps { - sh ''' - # Download SonarScanner CLI (command-line tool) - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip - - # Unzip the downloaded file - unzip -o sonar-scanner-cli-4.8.0.2856-linux.zip - - # Run the SonarScanner CLI to analyze your code and send results to SonarCloud - ./sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner - ''' + } + steps { + docker.image('sonarsource/sonar-scanner-cli:latest').inside { + sh 'sonar-scanner' + } } } } From bc29ab941edfcc53da45a6ed50c9c994c430fc6d Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:10:23 +1000 Subject: [PATCH 10/43] Update Jenkinsfile --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e80aef86630..87b4c19c43f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,8 +53,10 @@ pipeline { SONAR_TOKEN = credentials('SONAR_TOKEN') } steps { - docker.image('sonarsource/sonar-scanner-cli:latest').inside { + script{ + docker.image('sonarsource/sonar-scanner-cli:latest').inside { sh 'sonar-scanner' + } } } } From b1ea476095a58a60707135f2581d405ee2d19865 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:12:41 +1000 Subject: [PATCH 11/43] Update Jenkinsfile --- Jenkinsfile | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 87b4c19c43f..4fd33c15938 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,8 @@ pipeline { agent any + environment { + SONAR_TOKEN = credentials('SONAR_TOKEN') + } stages { stage('Checkout') { steps { @@ -8,7 +11,7 @@ pipeline { branches: [[name: '*/main']], userRemoteConfigs: [[ url: 'https://github.com/greenboy106/8.2CDevSecOps.git', - credentialsId: 'github-creds' + credentialsId: 'github-creds' // Ensure this credential exists or remove if public repo ]] ]) } @@ -49,16 +52,9 @@ pipeline { } } stage('SonarCloud Analysis') { - environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') - } - steps { - script{ - docker.image('sonarsource/sonar-scanner-cli:latest').inside { - sh 'sonar-scanner' - } + steps { + sh 'sonar-scanner' } - } } } } From d8f2c40be07100e636bca6245f2748629c51bc7f Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:28:47 +1000 Subject: [PATCH 12/43] Update Jenkinsfile --- Jenkinsfile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4fd33c15938..b40256bcbc5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent any environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') + SONAR_TOKEN = credentials('SONAR_TOKEN') // your SonarCloud token stored in Jenkins credentials } stages { stage('Checkout') { @@ -11,7 +11,7 @@ pipeline { branches: [[name: '*/main']], userRemoteConfigs: [[ url: 'https://github.com/greenboy106/8.2CDevSecOps.git', - credentialsId: 'github-creds' // Ensure this credential exists or remove if public repo + credentialsId: 'github-creds' ]] ]) } @@ -23,7 +23,7 @@ pipeline { } stage('Unit & Integration Tests') { steps { - sh 'npm test || true' + sh 'npm test || true' // continue even if tests fail } } stage('Static Code Analysis') { @@ -39,21 +39,34 @@ pipeline { stage('Deploy to Staging') { steps { echo 'Deploying to staging environment...' + // Add your real deploy commands here } } stage('Smoke Tests on Staging') { steps { echo 'Running smoke tests on staging...' + // Add real smoke test commands here } } stage('Deploy to Production') { steps { echo 'Deploying to production environment...' + // Add your real deploy commands here } } stage('SonarCloud Analysis') { steps { - sh 'sonar-scanner' + sh ''' + # Download SonarScanner CLI (skip if already downloaded) + if [ ! -d sonar-scanner-4.8.0.2856-linux ]; then + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip + unzip sonar-scanner-cli-4.8.0.2856-linux.zip + fi + + # Run SonarScanner with environment variable for token + ./sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ + -Dsonar.login=$SONAR_TOKEN + ''' } } } From 2f2f5ab2b6401328ca42252aa05e3c5ce5fa81fd Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:31:32 +1000 Subject: [PATCH 13/43] Update Jenkinsfile --- Jenkinsfile | 67 ++++++++++++++--------------------------------------- 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b40256bcbc5..eaf721313e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,71 +1,40 @@ pipeline { agent any + environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') // your SonarCloud token stored in Jenkins credentials + SONAR_TOKEN = credentials('sonar-token-id') // Replace with your Jenkins credential ID } + stages { stage('Checkout') { steps { - checkout([ - $class: 'GitSCM', - branches: [[name: '*/main']], - userRemoteConfigs: [[ - url: 'https://github.com/greenboy106/8.2CDevSecOps.git', - credentialsId: 'github-creds' - ]] - ]) + checkout scm } } - stage('Build') { + + stage('Install Dependencies') { steps { sh 'npm install' } } - stage('Unit & Integration Tests') { - steps { - sh 'npm test || true' // continue even if tests fail - } - } - stage('Static Code Analysis') { - steps { - echo 'Static analysis placeholder - add your tool here' - } - } - stage('Security Scan') { - steps { - sh 'npm audit --audit-level=low || true' - } - } - stage('Deploy to Staging') { - steps { - echo 'Deploying to staging environment...' - // Add your real deploy commands here - } - } - stage('Smoke Tests on Staging') { - steps { - echo 'Running smoke tests on staging...' - // Add real smoke test commands here - } - } - stage('Deploy to Production') { + + stage('Test') { steps { - echo 'Deploying to production environment...' - // Add your real deploy commands here + sh 'npm test' } } + stage('SonarCloud Analysis') { steps { sh ''' - # Download SonarScanner CLI (skip if already downloaded) - if [ ! -d sonar-scanner-4.8.0.2856-linux ]; then - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip - unzip sonar-scanner-cli-4.8.0.2856-linux.zip - fi - - # Run SonarScanner with environment variable for token - ./sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ - -Dsonar.login=$SONAR_TOKEN + # Download SonarScanner CLI for macOS + curl -LO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-macosx.zip + + # Unzip scanner + unzip -o sonar-scanner-cli-4.8.0.2856-macosx.zip + + # Run sonar-scanner with your token + ./sonar-scanner-4.8.0.2856-macosx/bin/sonar-scanner -Dsonar.login=$SONAR_TOKEN ''' } } From 7807a6a1ad8cb5bc9c20030406d2a0ca5e2f03a5 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:31:54 +1000 Subject: [PATCH 14/43] Update Jenkinsfile --- Jenkinsfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index eaf721313e0..4e31692c269 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,13 +27,10 @@ pipeline { stage('SonarCloud Analysis') { steps { sh ''' - # Download SonarScanner CLI for macOS curl -LO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-macosx.zip - # Unzip scanner unzip -o sonar-scanner-cli-4.8.0.2856-macosx.zip - # Run sonar-scanner with your token ./sonar-scanner-4.8.0.2856-macosx/bin/sonar-scanner -Dsonar.login=$SONAR_TOKEN ''' } From 87f7b879fabeda19cffd71d41ed3a4a88db8eb79 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:33:43 +1000 Subject: [PATCH 15/43] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4e31692c269..e174e1a6e0a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { - SONAR_TOKEN = credentials('sonar-token-id') // Replace with your Jenkins credential ID + SONAR_TOKEN = credentials('SONAR_TOKEN') // Replace with your Jenkins credential ID } stages { From b2c3e4c065732e14277b67b5bc116b00695b47ad Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:41:24 +1000 Subject: [PATCH 16/43] Update Jenkinsfile --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e174e1a6e0a..fa5defc2917 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') // Replace with your Jenkins credential ID + SONAR_TOKEN = credentials('SONAR_TOKEN') } stages { @@ -20,7 +20,11 @@ pipeline { stage('Test') { steps { - sh 'npm test' + withCredentials([string(credentialsId: 'snyk-token', variable: 'SNYK_TOKEN')]) { + sh ''' + snyk auth $SNYK_TOKEN + npm test + ''' } } From 8376fa21d51b3993ed35b028130ed0a2f5d50e81 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:44:22 +1000 Subject: [PATCH 17/43] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index fa5defc2917..da5faeb4f96 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { snyk auth $SNYK_TOKEN npm test ''' + } } } From f8b7f418a52ca16d5064748d80fcb3b047c6bd61 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:50:57 +1000 Subject: [PATCH 18/43] Update Jenkinsfile --- Jenkinsfile | 64 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index da5faeb4f96..078b057f974 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,44 +1,64 @@ pipeline { agent any - + environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') + SONAR_TOKEN = credentials('SONAR_TOKEN') // securely inject SonarCloud token } - + stages { stage('Checkout') { steps { - checkout scm + git branch: 'main', url: 'https://github.com/your_github_username/8.2CDevSecOps.git' } } - + stage('Install Dependencies') { steps { sh 'npm install' } } - - stage('Test') { + + stage('Run Tests') { steps { - withCredentials([string(credentialsId: 'snyk-token', variable: 'SNYK_TOKEN')]) { - sh ''' - snyk auth $SNYK_TOKEN - npm test - ''' - } + sh 'npm test || true' // continue even if tests fail } } - - stage('SonarCloud Analysis') { + + stage('Generate Coverage Report') { + steps { + sh 'npm run coverage || true' + } + } + + stage('NPM Audit (Security Scan)') { steps { - sh ''' - curl -LO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-macosx.zip - - unzip -o sonar-scanner-cli-4.8.0.2856-macosx.zip - - ./sonar-scanner-4.8.0.2856-macosx/bin/sonar-scanner -Dsonar.login=$SONAR_TOKEN - ''' + sh 'npm audit || true' } } + + stage('SonarCloud Analysis') { + steps { + script { + sh ''' + # Download SonarScanner CLI for macOS (Intel/M1 compatible) + curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-macosx.zip + + # Unzip (overwrite if exists) + unzip -o sonar-scanner.zip + + # Run SonarScanner + ./sonar-scanner-4.8.0.2856-macosx/bin/sonar-scanner \ + -Dsonar.projectKey=your_project_key \ + -Dsonar.organization=your_organization_name \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=$SONAR_TOKEN \ + -Dsonar.sources=. \ + -Dsonar.exclusions=node_modules/**,test/** \ + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + ''' + } + } +} + } } From 3e3c2f78beda765d0abcfb3195ec47aa30a205e2 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:52:05 +1000 Subject: [PATCH 19/43] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 078b057f974..cff7fad026b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,13 +2,13 @@ pipeline { agent any environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') // securely inject SonarCloud token + SONAR_TOKEN = credentials('SONAR_TOKEN') } stages { stage('Checkout') { steps { - git branch: 'main', url: 'https://github.com/your_github_username/8.2CDevSecOps.git' + git branch: 'main', url: 'https://github.com/greenboy106/8.2CDevSecOps.git' } } @@ -20,7 +20,7 @@ pipeline { stage('Run Tests') { steps { - sh 'npm test || true' // continue even if tests fail + sh 'npm test || true' } } From 787eb09c699445b00b84361885587bc9fbe61b09 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:54:13 +1000 Subject: [PATCH 20/43] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cff7fad026b..8d2cfed52e9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,7 +41,7 @@ pipeline { script { sh ''' # Download SonarScanner CLI for macOS (Intel/M1 compatible) - curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-macosx.zip + curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip # Unzip (overwrite if exists) unzip -o sonar-scanner.zip From e5ae0e9c3fcc1fff22f3faeede9dfd036117a92d Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 21:55:44 +1000 Subject: [PATCH 21/43] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8d2cfed52e9..439fd7f3b81 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,7 +47,7 @@ pipeline { unzip -o sonar-scanner.zip # Run SonarScanner - ./sonar-scanner-4.8.0.2856-macosx/bin/sonar-scanner \ + ./sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ -Dsonar.projectKey=your_project_key \ -Dsonar.organization=your_organization_name \ -Dsonar.host.url=https://sonarcloud.io \ From 33d197ad9cda38a6ad01104956d120a708c97009 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:02:08 +1000 Subject: [PATCH 22/43] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 439fd7f3b81..70aa31c563b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,13 +41,13 @@ pipeline { script { sh ''' # Download SonarScanner CLI for macOS (Intel/M1 compatible) - curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip + curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip # Unzip (overwrite if exists) unzip -o sonar-scanner.zip # Run SonarScanner - ./sonar-scanner-4.8.0.2856-linux/bin/sonar-scanner \ + ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ -Dsonar.projectKey=your_project_key \ -Dsonar.organization=your_organization_name \ -Dsonar.host.url=https://sonarcloud.io \ From 5a8474a18d236ce40ea6159c49b4670d2b4e7c15 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:04:00 +1000 Subject: [PATCH 23/43] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 70aa31c563b..0b82f1ecff3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,13 +41,13 @@ pipeline { script { sh ''' # Download SonarScanner CLI for macOS (Intel/M1 compatible) - curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli-4.8.0.2856-linux-aarch64.zip # Unzip (overwrite if exists) unzip -o sonar-scanner.zip # Run SonarScanner - ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ + ./sonar-scanner-cli-4.8.0.2856-linux-aarch64/bin/sonar-scanner \ -Dsonar.projectKey=your_project_key \ -Dsonar.organization=your_organization_name \ -Dsonar.host.url=https://sonarcloud.io \ From ecd41d213a426a6c9b5a514e73d28b830981d3d2 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:06:11 +1000 Subject: [PATCH 24/43] Update Jenkinsfile --- Jenkinsfile | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0b82f1ecff3..b14c1c89998 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,21 +40,17 @@ pipeline { steps { script { sh ''' - # Download SonarScanner CLI for macOS (Intel/M1 compatible) - curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli-4.8.0.2856-linux-aarch64.zip - - # Unzip (overwrite if exists) - unzip -o sonar-scanner.zip - - # Run SonarScanner - ./sonar-scanner-cli-4.8.0.2856-linux-aarch64/bin/sonar-scanner \ - -Dsonar.projectKey=your_project_key \ - -Dsonar.organization=your_organization_name \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.sources=. \ - -Dsonar.exclusions=node_modules/**,test/** \ - -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux-aarch64.zip + unzip sonar-scanner.zip + chmod +x sonar-scanner-4.8.0.2856-linux-aarch64/bin/sonar-scanner + java -version + ./sonar-scanner-4.8.0.2856-linux-aarch64/bin/sonar-scanner \ + -Dsonar.projectKey=your_project_key \ + -Dsonar.organization=your_org \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=$SONAR_TOKEN \ + -Dsonar.sources=. \ + -Dsonar.exclusions=node_modules/**,test/** ''' } } From 33e571b03bfc863d9414e4664444c939edf5d8f8 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:09:48 +1000 Subject: [PATCH 25/43] Update Jenkinsfile --- Jenkinsfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b14c1c89998..ec25a4c2c87 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,11 +40,10 @@ pipeline { steps { script { sh ''' - curl -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux-aarch64.zip - unzip sonar-scanner.zip - chmod +x sonar-scanner-4.8.0.2856-linux-aarch64/bin/sonar-scanner - java -version - ./sonar-scanner-4.8.0.2856-linux-aarch64/bin/sonar-scanner \ + curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner + ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ -Dsonar.projectKey=your_project_key \ -Dsonar.organization=your_org \ -Dsonar.host.url=https://sonarcloud.io \ From b6d6458caf7704b75277826126ffd0c280c4a71b Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:13:11 +1000 Subject: [PATCH 26/43] Update Jenkinsfile --- Jenkinsfile | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ec25a4c2c87..481bf34e7ce 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,24 +35,23 @@ pipeline { sh 'npm audit || true' } } - stage('SonarCloud Analysis') { - steps { - script { - sh ''' - curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip - unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip - chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner - ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ - -Dsonar.projectKey=your_project_key \ - -Dsonar.organization=your_org \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.sources=. \ - -Dsonar.exclusions=node_modules/**,test/** - ''' - } + steps { + script { + sh """ + curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-x86.zip + unzip sonar-scanner-cli-7.1.0.4889-linux-x86.zip + chmod +x sonar-scanner-cli-7.1.0.4889-linux-x86/bin/sonar-scanner + ./sonar-scanner-cli-7.1.0.4889-linux-x86/bin/sonar-scanner \ + -Dsonar.projectKey=your_project_key \ + -Dsonar.organization=your_org \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.sources=. \ + -Dsonar.exclusions=node_modules/**,test/** + """ } + } } } From e22e286bf3d283af79c052f924e5e21e2c76a7c3 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:16:59 +1000 Subject: [PATCH 27/43] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 481bf34e7ce..b8c6343bd83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,8 +43,8 @@ pipeline { unzip sonar-scanner-cli-7.1.0.4889-linux-x86.zip chmod +x sonar-scanner-cli-7.1.0.4889-linux-x86/bin/sonar-scanner ./sonar-scanner-cli-7.1.0.4889-linux-x86/bin/sonar-scanner \ - -Dsonar.projectKey=your_project_key \ - -Dsonar.organization=your_org \ + -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ + -Dsonar.organization=greenboy106 \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=${SONAR_TOKEN} \ -Dsonar.sources=. \ From 53d530f76fb724a9aa0fed8d34804a85271fe557 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:19:04 +1000 Subject: [PATCH 28/43] Update Jenkinsfile --- Jenkinsfile | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b8c6343bd83..2407b2557d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,21 +38,22 @@ pipeline { stage('SonarCloud Analysis') { steps { script { - sh """ - curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-x86.zip - unzip sonar-scanner-cli-7.1.0.4889-linux-x86.zip - chmod +x sonar-scanner-cli-7.1.0.4889-linux-x86/bin/sonar-scanner - ./sonar-scanner-cli-7.1.0.4889-linux-x86/bin/sonar-scanner \ - -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ - -Dsonar.organization=greenboy106 \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=${SONAR_TOKEN} \ - -Dsonar.sources=. \ - -Dsonar.exclusions=node_modules/**,test/** - """ + sh ''' + curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner + ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ + -Dsonar.projectKey=your_project_key \ + -Dsonar.organization=your_org \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=$SONAR_TOKEN \ + -Dsonar.sources=. \ + -Dsonar.exclusions=node_modules/**,test/** + ''' + } } - } } } } +} From 9ab6356b8d7cfd5919c6c1cee44d4897a9a3e5f4 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:19:49 +1000 Subject: [PATCH 29/43] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2407b2557d3..f7a8bc787b3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,8 +43,8 @@ pipeline { unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ - -Dsonar.projectKey=your_project_key \ - -Dsonar.organization=your_org \ + -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ + -Dsonar.organization=greenboy106 \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=$SONAR_TOKEN \ -Dsonar.sources=. \ From 3dac680205ccc796a18125ba07dc0c6b9420ce6b Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:21:39 +1000 Subject: [PATCH 30/43] Update Jenkinsfile --- Jenkinsfile | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f7a8bc787b3..955b51a4a6b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,22 +38,21 @@ pipeline { stage('SonarCloud Analysis') { steps { script { - sh ''' - curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip - unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip - chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner - ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ - -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ - -Dsonar.organization=greenboy106 \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN \ - -Dsonar.sources=. \ - -Dsonar.exclusions=node_modules/**,test/** - ''' - } + sh """ + curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux.zip + unzip sonar-scanner-cli-7.1.0.4889-linux.zip + chmod +x sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner + ./sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner \ + -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ + -Dsonar.organization=greenboy106 \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.sources=. \ + -Dsonar.exclusions=node_modules/**,test/** + """ } + } +} } - - } } } From 8ca09d848abb606238e7064410bf10c74607f31e Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:22:55 +1000 Subject: [PATCH 31/43] Update Jenkinsfile --- Jenkinsfile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 955b51a4a6b..18bf7e1d224 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,24 +35,24 @@ pipeline { sh 'npm audit || true' } } + stage('SonarCloud Analysis') { - steps { - script { - sh """ - curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux.zip - unzip sonar-scanner-cli-7.1.0.4889-linux.zip - chmod +x sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner - ./sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner \ - -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ - -Dsonar.organization=greenboy106 \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=${SONAR_TOKEN} \ - -Dsonar.sources=. \ - -Dsonar.exclusions=node_modules/**,test/** - """ + steps { + script { + sh """ + curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux.zip + unzip sonar-scanner-cli-7.1.0.4889-linux.zip + chmod +x sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner + ./sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner \ + -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ + -Dsonar.organization=greenboy106 \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.sources=. \ + -Dsonar.exclusions=node_modules/**,test/** + """ + } + } + } } - } -} -} -} } From d8960f0c26c21b189e75eba064510666e38163f4 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:25:44 +1000 Subject: [PATCH 32/43] Update Jenkinsfile --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 18bf7e1d224..2b15a1517b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') + SONAR_TOKEN = credentials('SONAR_TOKEN') } stages { @@ -20,7 +20,7 @@ pipeline { stage('Run Tests') { steps { - sh 'npm test || true' + sh 'npm test || true' } } @@ -39,7 +39,8 @@ pipeline { stage('SonarCloud Analysis') { steps { script { - sh """ + sh ''' + set -ex curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux.zip unzip sonar-scanner-cli-7.1.0.4889-linux.zip chmod +x sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner @@ -50,7 +51,7 @@ pipeline { -Dsonar.login=${SONAR_TOKEN} \ -Dsonar.sources=. \ -Dsonar.exclusions=node_modules/**,test/** - """ + ''' } } } From 4bb608b6d9e662634b237d35897836aa3a4ff820 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:34:46 +1000 Subject: [PATCH 33/43] Update Jenkinsfile --- Jenkinsfile | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2b15a1517b6..1586ce85532 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,41 +1,66 @@ pipeline { agent any - + environment { SONAR_TOKEN = credentials('SONAR_TOKEN') } - + stages { + stage('Checkout') { steps { git branch: 'main', url: 'https://github.com/greenboy106/8.2CDevSecOps.git' } } - - stage('Install Dependencies') { + + stage('Build') { steps { - sh 'npm install' + sh 'npm run build || echo "Build step placeholder"' } } - - stage('Run Tests') { + + stage('Unit and Integration Tests') { steps { sh 'npm test || true' } } - - stage('Generate Coverage Report') { + + stage('Code Analysis') { steps { - sh 'npm run coverage || true' + sh 'npm run lint || echo "Code analysis placeholder"' } } - - stage('NPM Audit (Security Scan)') { + + stage('Security Scan') { steps { sh 'npm audit || true' } } - + + stage('Deploy to Staging') { + steps { + sh 'echo "Deploying application to staging server - placeholder"' + } + } + + stage('Integration Tests on Staging') { + steps { + sh 'echo "Running integration tests on staging - placeholder"' + } + } + + stage('Deploy to Production') { + steps { + sh 'echo "Deploying application to production server - placeholder"' + } + } + + stage('Generate Coverage Report') { + steps { + sh 'npm run coverage || true' + } + } + stage('SonarCloud Analysis') { steps { script { From f45b004ea32ff5b5b813d658fa40cdba6653cfa5 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:35:44 +1000 Subject: [PATCH 34/43] Update Jenkinsfile --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1586ce85532..492ea703f7b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,10 +66,10 @@ pipeline { script { sh ''' set -ex - curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux.zip - unzip sonar-scanner-cli-7.1.0.4889-linux.zip - chmod +x sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner - ./sonar-scanner-cli-7.1.0.4889-linux/bin/sonar-scanner \ + curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip + chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner + ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ -Dsonar.organization=greenboy106 \ -Dsonar.host.url=https://sonarcloud.io \ From 1a8bf21e10f250e1279297cf32fceeae1efe59a6 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:38:08 +1000 Subject: [PATCH 35/43] Update Jenkinsfile --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 492ea703f7b..c494e20890b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -61,6 +61,13 @@ pipeline { } } + stage('Build') { + steps { + sh 'npm run build || true' + } + } + + stage('SonarCloud Analysis') { steps { script { From 0cde7301001d6a6a764f4ac259cae8c0c3682dc5 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:40:55 +1000 Subject: [PATCH 36/43] Update Jenkinsfile --- Jenkinsfile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c494e20890b..b9d1cbd4646 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { stage('Build') { steps { - sh 'npm run build || echo "Build step placeholder"' + sh 'npm run build || true' } } @@ -61,13 +61,6 @@ pipeline { } } - stage('Build') { - steps { - sh 'npm run build || true' - } - } - - stage('SonarCloud Analysis') { steps { script { From f69499e7c45148863aefdca00d91702feefbd37d Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:44:24 +1000 Subject: [PATCH 37/43] Update Jenkinsfile --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b9d1cbd4646..578ce88125e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,25 +15,25 @@ pipeline { stage('Build') { steps { - sh 'npm run build || true' + sh 'npm run build' } } stage('Unit and Integration Tests') { steps { - sh 'npm test || true' + sh 'npm test' } } stage('Code Analysis') { steps { - sh 'npm run lint || echo "Code analysis placeholder"' + sh 'npm run lint' } } stage('Security Scan') { steps { - sh 'npm audit || true' + sh 'npm audit' } } @@ -57,7 +57,7 @@ pipeline { stage('Generate Coverage Report') { steps { - sh 'npm run coverage || true' + sh 'npm run coverage' } } From 45d5dce42dc15d7fff3a92e3065cb03725321299 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Wed, 28 May 2025 22:45:53 +1000 Subject: [PATCH 38/43] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 578ce88125e..4ffbfd5ff56 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { stage('Unit and Integration Tests') { steps { - sh 'npm test' + sh 'npm test|| true' } } From 87bd8a609240b233bc000fd67aaadea7be476880 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Thu, 29 May 2025 12:16:06 +1000 Subject: [PATCH 39/43] Update Jenkinsfile --- Jenkinsfile | 101 ++++++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 75 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4ffbfd5ff56..d817a796838 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,84 +1,35 @@ pipeline { - agent any + agent any - environment { - SONAR_TOKEN = credentials('SONAR_TOKEN') + stages { + stage('Checkout') { + steps { + git branch: 'main', url: 'https://github.com//8.2CDevSecOps.git' + } } - stages { - - stage('Checkout') { - steps { - git branch: 'main', url: 'https://github.com/greenboy106/8.2CDevSecOps.git' - } - } - - stage('Build') { - steps { - sh 'npm run build' - } - } - - stage('Unit and Integration Tests') { - steps { - sh 'npm test|| true' - } - } - - stage('Code Analysis') { - steps { - sh 'npm run lint' - } - } - - stage('Security Scan') { - steps { - sh 'npm audit' - } - } - - stage('Deploy to Staging') { - steps { - sh 'echo "Deploying application to staging server - placeholder"' - } - } - - stage('Integration Tests on Staging') { - steps { - sh 'echo "Running integration tests on staging - placeholder"' - } - } + stage('Install Dependencies') { + steps { + sh 'npm install' + } + } - stage('Deploy to Production') { - steps { - sh 'echo "Deploying application to production server - placeholder"' - } - } + stage('Run Tests') { + steps { + sh 'npm test || true' + } + } - stage('Generate Coverage Report') { - steps { - sh 'npm run coverage' - } - } + stage('Generate Coverage Report') { + steps { + sh 'npm run coverage || true' + } + } - stage('SonarCloud Analysis') { - steps { - script { - sh ''' - set -ex - curl -O https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip - unzip sonar-scanner-cli-7.1.0.4889-linux-aarch64.zip - chmod +x sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner - ./sonar-scanner-cli-7.1.0.4889-linux-aarch64/bin/sonar-scanner \ - -Dsonar.projectKey=e16a4a978fab88d437078b4b4252d9dd91e1f0a9 \ - -Dsonar.organization=greenboy106 \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=${SONAR_TOKEN} \ - -Dsonar.sources=. \ - -Dsonar.exclusions=node_modules/**,test/** - ''' - } - } - } + stage('NPM Audit (Security Scan)') { + steps { + sh 'npm audit || true' + } } + } } From 469b44f531d43e6b32b05890f16384f5db6a48fd Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Thu, 29 May 2025 12:18:38 +1000 Subject: [PATCH 40/43] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d817a796838..11fb0d32021 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stages { stage('Checkout') { steps { - git branch: 'main', url: 'https://github.com//8.2CDevSecOps.git' + git branch: 'main', url: 'https://github.com/greenboy106/8.2CDevSecOps.git' } } From eea87b9eef7cb7b996b149e8c60908cc994ebfe1 Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Thu, 29 May 2025 12:41:12 +1000 Subject: [PATCH 41/43] Update Jenkinsfile --- Jenkinsfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 11fb0d32021..d7240b1f6f2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,4 +32,25 @@ pipeline { } } } + + post { + always { + emailext( + subject: "Jenkins Build - ${env.JOB_NAME} #${env.BUILD_NUMBER}", + body: """ + Hello, + + Jenkins has completed a build for the project: ${env.JOB_NAME} + Result: ${currentBuild.currentResult} + + You can view the full console output here: + ${env.BUILD_URL}console + + Regards, + Jenkins Server + """, + to: "giabao157248@gmail.com" + ) + } + } } From 9c10749dad01c88a17788193e1edfdb74735c5de Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Thu, 29 May 2025 13:04:40 +1000 Subject: [PATCH 42/43] Update Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index d7240b1f6f2..78fcd748593 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,6 +51,9 @@ pipeline { """, to: "giabao157248@gmail.com" ) + } catch (e) { + echo "Failed to send email: ${e.message}" } } } +} From 6da351f0499d8377541c9009a2ea17920669056a Mon Sep 17 00:00:00 2001 From: Mat Nguyen <164964696+greenboy106@users.noreply.github.com> Date: Thu, 29 May 2025 13:05:39 +1000 Subject: [PATCH 43/43] Update Jenkinsfile --- Jenkinsfile | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 78fcd748593..c0a95979271 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,25 +35,28 @@ pipeline { post { always { - emailext( - subject: "Jenkins Build - ${env.JOB_NAME} #${env.BUILD_NUMBER}", - body: """ - Hello, - - Jenkins has completed a build for the project: ${env.JOB_NAME} - Result: ${currentBuild.currentResult} - - You can view the full console output here: - ${env.BUILD_URL}console - - Regards, - Jenkins Server - """, - to: "giabao157248@gmail.com" - ) + script { + try { + emailext( + subject: "Jenkins Build - ${env.JOB_NAME} #${env.BUILD_NUMBER}", + body: """ + Hello, + + Jenkins has completed a build for the project: ${env.JOB_NAME} + Result: ${currentBuild.currentResult} + + You can view the full console output here: + ${env.BUILD_URL}console + + Regards, + Jenkins Server + """, + to: "giabao157248@gmail.com" + ) } catch (e) { - echo "Failed to send email: ${e.message}" + echo "Failed to send email: ${e.message}" + } + } } } } -}