All checks were successful
InnoHub Processor/tatort/pipeline/head This commit was not built
103 lines
3.4 KiB
Groovy
103 lines
3.4 KiB
Groovy
def didRun = false
|
|
|
|
pipeline {
|
|
agent any
|
|
|
|
tools {
|
|
nodejs 'NodeJS-24.2.0'
|
|
}
|
|
|
|
environment {
|
|
REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/'
|
|
USER = 'jenkins'
|
|
TOKEN = credentials('JenkinsGitea')
|
|
}
|
|
|
|
parameters {
|
|
string(name: 'REPO_NAME', defaultValue: '', description: 'Repo Name')
|
|
string(name: 'GIT_REF', defaultValue: '', description: 'Git Ref')
|
|
}
|
|
|
|
options {
|
|
buildDiscarder(
|
|
BuildHistoryManager([
|
|
[ continueAfterMatch: false, matchAtMost: 5 ],
|
|
[ actions: [ DeleteBuild() ] ]
|
|
])
|
|
)
|
|
}
|
|
|
|
stages {
|
|
stage('Validate Run Parameters') {
|
|
steps {
|
|
script {
|
|
def jobParts = env.JOB_NAME.tokenize('/')
|
|
def detectedRepo = jobParts[1]
|
|
|
|
echo "Detected Repo: ${detectedRepo}"
|
|
echo "Provided REPO_NAME: ${params.REPO_NAME}"
|
|
|
|
if (params.REPO_NAME != detectedRepo) {
|
|
echo "Skipping build. REPO_NAME '${params.REPO_NAME}' does not match repo '${detectedRepo}'"
|
|
currentBuild.result = 'NOT_BUILT'
|
|
error("Stopping pipeline as REPO_NAME does not match repository.")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Install Dependencies') {
|
|
steps {
|
|
script {
|
|
didRun = true
|
|
}
|
|
sh 'npm ci'
|
|
}
|
|
}
|
|
|
|
stage('Test & Security Audit') {
|
|
steps {
|
|
script {
|
|
didRun = true
|
|
}
|
|
echo 'Start checking security vulnerabilities in npm packages'
|
|
sh 'npm audit --audit-level=moderate'
|
|
}
|
|
}
|
|
|
|
stage('Push image to gitea registry') {
|
|
when {
|
|
branch 'development'
|
|
}
|
|
steps {
|
|
script {
|
|
didRun = true
|
|
def tag = "innohub/tatort-dev:0.${env.BUILD_ID}"
|
|
docker.withRegistry('https://gitea.innovation-hub-niedersachsen.de', 'JenkinsGitea') {
|
|
docker.build(tag, '-f Dockerfile.dev .').push('latest')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
script {
|
|
if (didRun) {
|
|
echo 'Pipeline erfolgreich!'
|
|
discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline succeeded', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc'
|
|
}
|
|
}
|
|
}
|
|
failure {
|
|
script {
|
|
if (didRun) {
|
|
echo 'Pipeline fehlgeschlagen!'
|
|
discordSend description: "Running ${env.BUILD_ID} on ${env.JENKINS_URL}, ${params.GIT_REF}", footer: 'Pipeline failed', link: env.BUILD_URL, result: currentBuild.currentResult, title: env.JOB_NAME, webhookURL: 'https://discordapp.com/api/webhooks/1389470542691831819/NdMO17sLBG2dplp_-oh6Ff0cbPOoADl0QwXKM9UzduxU44av_ZQkQjKTmpdK7YuwcZDc'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|