test branch main2 und try catch blocke in jenkinsfile

This commit is contained in:
ISA
2024-07-13 21:28:09 +02:00
parent e8d0a7ddcd
commit 5452a6e50e

19
Jenkinsfile vendored
View File

@@ -10,19 +10,29 @@ pipeline {
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { steps {
script {
try {
// Code aus dem Repository holen // Code aus dem Repository holen
git branch: 'main2', url: 'http://localhost:3003/Ismail/NodeMap.git' git branch: 'main2', url: 'http://localhost:3003/Ismail/NodeMap.git'
} catch (Exception e) {
error "Branch 'main2' exists nicht im Repository"
}
}
} }
} }
stage('Install Dependencies') { stage('Install Dependencies') {
steps { steps {
script { script {
try {
// Node.js Version setzen // Node.js Version setzen
nodejs('nodejs') { nodejs('nodejs') {
// Abhängigkeiten installieren // Abhängigkeiten installieren
sh 'npm install' sh 'npm install'
} }
} catch (Exception e) {
error "Dependency Installation failed: ${e.message}"
}
} }
} }
} }
@@ -30,10 +40,14 @@ pipeline {
stage('Build') { stage('Build') {
steps { steps {
script { script {
try {
nodejs('nodejs') { nodejs('nodejs') {
// Projekt bauen // Projekt bauen
sh 'npm run build' sh 'npm run build'
} }
} catch (Exception e) {
error "Build failed: ${e.message}"
}
} }
} }
} }
@@ -41,10 +55,14 @@ pipeline {
stage('Test') { stage('Test') {
steps { steps {
script { script {
try {
nodejs('nodejs') { nodejs('nodejs') {
// Tests ausführen // Tests ausführen
sh 'npm test' sh 'npm test'
} }
} catch (Exception e) {
error "Tests failed: ${e.message}"
}
} }
} }
} }
@@ -59,3 +77,4 @@ pipeline {
} }
} }
} }