-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_test_server
91 lines (90 loc) · 2.74 KB
/
Jenkinsfile_test_server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
pipeline {
agent {
kubernetes {
defaultContainer "nodejs"
yaml '''
apiVersion: v1
kind: Pod
spec:
nodeSelector:
role: devops
containers:
- name: nodejs
image: node:22.12.0-alpine
command:
- cat
tty: true
'''
}
}
environment {
S3_BUCKET = 'linket-test-web20241216150840500300000001'
AWS_DEFAULT_REGION = 'ap-northeast-2'
}
stages {
stage('Install Git') {
steps {
sh 'apk update && apk add git'
}
}
stage('Configure Git Safe Directory') {
steps {
sh "git config --global --add safe.directory '*'"
}
}
stage('Checkout') {
steps {
// checkout scm
script {
env.GIT_COMMIT_SHORT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
env.GIT_COMMIT_MESSAGE = sh(script: 'git log -1 --pretty=%B', returnStdout: true).trim()
echo "Current Git Commit Short: ${env.GIT_COMMIT_SHORT}"
echo "Git Commit Message: ${env.GIT_COMMIT_MESSAGE}"
}
}
}
stage('Install Dependencies') {
steps {
sh 'npm install'
}
}
stage('Build') {
steps {
sh 'npm run build-test'
}
}
stage('Deploy to S3') {
steps {
withAWS(region: "${AWS_DEFAULT_REGION}", credentials: 'AWS_CREDENTIALS') {
s3Upload(
//acl: 'PublicRead',
bucket: "${S3_BUCKET}",
path: '',
workingDir: 'dist',
includePathPattern: '**/*'
)
}
}
}
}
post {
always {
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
}
echo "Build Result: ${currentBuild.result}"
withCredentials([string(credentialsId: 'Discord-Webhook-test', variable: 'DISCORD')]) {
discordSend(
title: "Build Result: ${env.JOB_NAME}",
description: """
**Commit Message**: `${env.GIT_COMMIT_MESSAGE}`
**Commit ID**: `${env.GIT_COMMIT_SHORT}`
**Build Number**: `#${env.BUILD_NUMBER}`
**Status**: ${currentBuild.result == 'SUCCESS' ? '🟢 **Success**' : '❌ **Failure**'}
""",
webhookURL: DISCORD
)
}
}
}
}