diff --git a/Dockerfile.dev b/Dockerfile.dev index 81e9c36..3a1a399 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -6,7 +6,7 @@ WORKDIR /app COPY package*.json ./ RUN npm ci COPY . ./ -COPY config.json_dev ./config.json +COPY config_dev.json ./config.json RUN npm run build # --- Production stage --- diff --git a/Dockerfile.prod b/Dockerfile.prod index 2d92413..66a3f39 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -6,7 +6,7 @@ WORKDIR /app COPY package*.json ./ RUN npm ci COPY . ./ -COPY config.json_prod ./config.json +COPY config_prod.json ./config.json RUN npm run build # --- Production stage --- diff --git a/Jenkinsfile b/Jenkinsfile index 8b23f23..eba846e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +def didRun = false + pipeline { agent any @@ -7,9 +9,8 @@ pipeline { environment { REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/' - IMAGE = 'tatort-app' - USER = 'jared' - TOKEN = credentials('c661e484bb4f032f8a0a5b02cda6f3344ca584b5') + USER = 'jenkins' + TOKEN = credentials('JenkinsGitea') } parameters { @@ -29,47 +30,55 @@ pipeline { stages { 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' + 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') + } + } } } } - // stage('Build') { - // when { - // branch 'development' - // } - // steps { - // sh 'npm run build' - // } - // } - - // stage('Push image in gitea registry') { - // steps { - // echo 'Start Pushing' - // script { - // docker.withRegistry('https://gitea.innovation-hub-niedersachsen.de', 'JenkinsGitea') { - // docker.build('innohub/tatort-app').push('latest') - // } - // } - // } - // } - // } - - // post { - // success { - // 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 { - // 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' - // } - // } + 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' + } + } + } + } } diff --git a/config_dev.json b/config_dev.json new file mode 100644 index 0000000..8ab9cb8 --- /dev/null +++ b/config_dev.json @@ -0,0 +1,17 @@ +{ + "minio": { + "endPoint": "sws3.innovation-hub-niedersachsen.de", + "port": 443, + "useSSL": true, + "accessKey": "wjpKrmaqXra99rX3D61H", + "secretKey": "fTPi0u0FR6Lv9Y9IKydWv6WM0EA5XrsK008HCt9u" + }, + "jwt": { + "secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB", + "expiresIn": 3600 + }, + "auth": { + "admin": { "password": "A-InnoHUB_2025!", "admin": true }, + "user": { "password": "U-InnoHUB_2025!", "admin": false } + } +} \ No newline at end of file diff --git a/config.json b/config_prod.json similarity index 94% rename from config.json rename to config_prod.json index 8490de6..126d80d 100644 --- a/config.json +++ b/config_prod.json @@ -8,10 +8,10 @@ }, "jwt": { "secret": "@S2!q@@wXz$dCQ8JoVsHLpzaJ6JCfB", - "expiresIn": 36000 + "expiresIn": 3600 }, "auth": { "admin": { "password": "A-InnoHUB_2025!", "admin": true }, "user": { "password": "U-InnoHUB_2025!", "admin": false } } -} +} \ No newline at end of file