-
Notifications
You must be signed in to change notification settings - Fork 40
/
Jenkinsfile
52 lines (41 loc) · 1.43 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
pipeline {
agent any
tools {nodejs "node"}
environment {
DOCKER_REPO = 'chyke007/yumfood' // Replace with your Docker Hub username and repository name
IMAGE_TAG = "1.0.1" // Replace with the desired tag for your Docker image
}
stages {
stage('Install dependencies') {
steps {
sh 'npm install'
echo 'Installing dependecies found in branch: ' + env.BRANCH_NAME
}
}
stage('Unit Test stage') {
steps {
sh 'npm run test'
}
}
stage('Integration Test stage') {
steps {
sh 'npm run integration-test'
}
}
stage('Build App Docker Images') {
steps {
echo 'Building App Images'
sh 'cp frontend/.env.example frontend/.env'
sh 'docker build -t ${DOCKER_REPO}:${IMAGE_TAG} .'
}
}
stage('Push to Docker Hub') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', passwordVariable: 'DOCKER_PASSWORD', usernameVariable: 'DOCKER_USERNAME')]) {
sh "docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}"
sh "docker push ${DOCKER_REPO}:${IMAGE_TAG}"
}
}
}
}
}