From 4d099ef96a2e8686a762a970fe8f54ad59bad06d Mon Sep 17 00:00:00 2001 From: first_admin Date: Sun, 1 Sep 2024 08:19:07 +0000 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22076ae..a4614ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,9 +9,11 @@ pipeline { stage('Pre-Build Check') { steps { script { - // Pobierz aktualne ustawienia rejestru npm i wyświetl je w logach + // Pobierz aktualne ustawienia rejestru npm def registry = sh(script: 'npm config get registry', returnStdout: true).trim() - echo "Aktualnie ustawiony rejestr npm: ${registry}" + + // Zapisz ustawiony rejestr do pliku logu + sh "echo 'Aktualnie ustawiony rejestr npm: ${registry}' > registry.log" // Sprawdź, czy ustawione jest właściwe wewnętrzne repozytorium if (registry != EXPECTED_REGISTRY) { @@ -26,21 +28,21 @@ pipeline { steps { echo "Installing dependencies..." // Zainstaluj zależności npm - sh 'npm install' + sh 'npm install >> registry.log 2>&1' // Dodanie do logu } } stage('Build') { steps { // Zapisz logi builda do pliku - sh 'npm run build > build.log 2>&1' + sh 'npm run build >> registry.log 2>&1' // Dodanie do logu echo "Building..." } } stage('Post-Build Check') { steps { script { - // Przeczytaj logi z pliku build.log - def logs = readFile('build.log') + // Przeczytaj logi z połączonego pliku logów + def logs = readFile('registry.log') // Wydrukuj logi dla debugowania (opcjonalnie) echo "---- POCZĄTEK LOGÓW ----" @@ -49,12 +51,4 @@ pipeline { // Sprawdź, czy logi zawierają niedozwolony adres URL 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." - } - } - } - } - } -} + error("Błąd: W logach builda wykryto dostęp do zewnętr