-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
101 lines (86 loc) · 2.78 KB
/
Jenkinsfile
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
92
93
94
95
96
97
98
99
100
101
pipeline {
agent {
label env.AGENT
}
tools {
nodejs 'nodejs-20.11.1'
}
environment {
REPO_URL = 'https://github.com/Ontotext-AD/ontotext-graphql-playground'
GIT_PIPELINE = "Ontotext GraphQL Playground Component"
COMPOSE_PROJECT_NAME = "${JOB_NAME}_${BUILD_NUMBER}"
}
stages {
stage('Build Info') {
steps {
script {
echo "Agent: ${env.AGENT}"
echo "Building branch: ${env.BRANCH_NAME}"
}
}
}
stage('Log Info') {
steps {
echo "Pipeline: ${GIT_PIPELINE}"
echo "Repository: ${REPO_URL}"
}
}
stage('Install & Build') {
steps {
// Export COMPOSE_PROJECT_NAME for use in docker-compose
sh "export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}"
sh 'docker-compose -p ${COMPOSE_PROJECT_NAME} up --build --abort-on-container-exit'
sh 'npm run install:component:ci'
sh 'npm run build:component'
}
}
stage('Align folder permissions') {
steps {
sh 'sudo chown -R \$(id -u):\$(id -g) .'
}
}
stage('Lint') {
steps {
sh 'npm run lint'
}
}
stage('Test') {
steps {
sh 'npm run test'
}
}
stage('Cypress Test') {
steps {
sh 'npm run cy:run'
}
}
}
post {
always {
sh "docker-compose -p ${COMPOSE_PROJECT_NAME} down --remove-orphans --rmi all || true"
}
success {
updateGitlabCommitStatus name: "${GIT_PIPELINE}", state: 'success'
echo "Build successful - GitLab commit status updated."
}
unstable {
updateGitlabCommitStatus name: "${GIT_PIPELINE}", state: 'failed'
echo "Build unstable - GitLab commit status updated as failed."
}
failure {
updateGitlabCommitStatus name: "${GIT_PIPELINE}", state: 'failed'
echo "Build failed - GitLab commit status updated as failed."
emailext(
to: env.GITLAB_USER_EMAIL,
from: "Jenkins <[email protected]>",
subject: '''[Jenkins] $PROJECT_NAME - Build #$BUILD_NUMBER - Failed!''',
mimeType: 'text/html',
body: '''${SCRIPT, template="groovy-html.template"}'''
)
}
aborted {
updateGitlabCommitStatus name: "${GIT_PIPELINE}", state: 'canceled'
echo "Build aborted - GitLab commit status updated as canceled."
}
}
}