From 547186dd37229134af83d0b416c3ca6ba014bb73 Mon Sep 17 00:00:00 2001 From: first_admin Date: Sun, 1 Sep 2024 07:56:05 +0000 Subject: [PATCH] Add Jenkinsfile --- Jenkinsfile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..912b70f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,53 @@ +pipeline { + agent any + environment { + // EXPECTED_REGISTRY = 'http://:/artifactory/api/npm//' + EXPECTED_REGISTRY = 'https://registry.npmjs.org/' + } + stages { + stage('Pre-Build Check') { + steps { + script { + // Pobierz aktualne ustawienia rejestru npm + def registry = sh(script: 'npm config get registry', returnStdout: true).trim() + + // Sprawdź, czy ustawione jest właściwe wewnętrzne repozytorium + if (registry != EXPECTED_REGISTRY) { + error("Błąd: Rejestr npm jest ustawiony na '${registry}', a powinien być '${EXPECTED_REGISTRY}'.") + } else { + echo "Rejestr npm jest poprawnie ustawiony na '${registry}'." + } + } + } + } + stage('Install Dependencies') { + steps { + // sh 'npm install' + echo "Installing dependendencies..." + } + } + stage('Build') { + steps { + // sh 'npm run build' + // echo "Building..." + + // Zapisz logi builda do pliku + sh 'npm run build > build.log 2>&1' + echo "Building..." + } + } + stage('Post-Build Check') { + steps { + script { + // Przeszukaj logi builda pod kątem podejrzanych URL-i + def logs = currentBuild.rawBuild.getLog(1000).join('\n') + if (logs.contains('https://registry.npmjs.org')) { + error("Błąd: W logach builda wykryto dostęp do zewnętrznego repozytorium npm!") + } else { + echo "W logach builda nie wykryto żadnych nieautoryzowanych repozytoriów." + } + } + } + } + } +}