commit 8b24a6dccc7249fa7091fc11917c20fd8e5bf94c Author: jenkins Date: Sat Aug 24 07:55:23 2024 +0000 Add Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..4380b50 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,41 @@ +pipeline { + agent any + stages { + stage('Retrieve artifacts') { + steps { + copyArtifacts(projectName: 'some-project', selector: lastSuccessful()) // Zakładamy pobranie z ostatniego udanego builda + } + } + stage('Check user') { + steps { + script { + def user = readFile('user.txt').trim() + if (user != 'service-jenkins-ci') { + // Informujemy użytkownika + echo "Artefakt został stworzony przez nieautoryzowanego użytkownika: ${user}" + + // Zapytanie użytkownika, czy kontynuować + def userInput = input message: 'Czy chcesz kontynuować?', + ok: 'Tak', + submitter: 'service-jenkins-ci,admin', + parameters: [booleanParam(defaultValue: false, description: 'Kontynuować pomimo nieautoryzowanego użytkownika?', name: 'kontynuacja')] + + if (!userInput) { + echo "Przerywam wykonanie, ponieważ użytkownik wybrał, aby nie kontynuować." + currentBuild.result = 'ABORTED' + error "Proces przerwany przez użytkownika." + } + } else { + echo "Artefakt został stworzony przez autoryzowanego użytkownika: ${user}" + } + } + } + } + stage('Use artifact') { + steps { + echo "Używanie artefaktu..." + // Tutaj dodajesz kod użycia artefaktu + } + } + } +}