jenkins test webhook Gitea test 22 jenkinsfile
This commit is contained in:
68
Jenkinsfile
vendored
68
Jenkinsfile
vendored
@@ -1,77 +1,17 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
tools {
|
||||||
NODE_ENV = 'production'
|
nodejs 'nodejs' // Ensure this matches the name defined in Jenkins
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Check Node.js Version') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
try {
|
sh 'node --version'
|
||||||
// Code aus dem Repository holen
|
|
||||||
git branch: 'develop', url: 'http://172.19.0.2:3000/Ismail/NodeMap.git'
|
|
||||||
} catch (Exception e) {
|
|
||||||
error "Branch 'develop' exists nicht im Repository"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Install Dependencies') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
try {
|
|
||||||
// Node.js Version setzen
|
|
||||||
nodejs('nodejs') {
|
|
||||||
// Abhängigkeiten installieren
|
|
||||||
sh 'npm install'
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
error "Dependency Installation failed: ${e.message}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
try {
|
|
||||||
nodejs('nodejs') {
|
|
||||||
// Projekt bauen
|
|
||||||
sh 'npm run build'
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
error "Build failed: ${e.message}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Test') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
try {
|
|
||||||
nodejs('nodejs') {
|
|
||||||
// Tests ausführen
|
|
||||||
sh 'npm test'
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
error "Tests failed: ${e.message}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
post {
|
|
||||||
success {
|
|
||||||
echo 'Build and tests were successful!'
|
|
||||||
}
|
|
||||||
failure {
|
|
||||||
echo 'Build or tests failed.'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user