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

43
Jenkinsfile vendored
View File

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