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