forked from nirmalyax/React-folio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
55 lines (55 loc) · 1.69 KB
/
Jenkinsfile
File metadata and controls
55 lines (55 loc) · 1.69 KB
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
pipeline{
agent any
tools {
nodejs 'nodejs'
}
stages{
stage('Checkout'){
steps{
echo 'Checkout the project'
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/nirmalyax/React-folio']])
}
}
stage('NPM Install'){
steps{
echo 'Installing the dependencies'
// sh 'sudo apt install npm'
// sh 'sudo apt install nodejs'
}
}
stage('Build'){
steps{
echo 'Building the project'
sh 'npm install'
}
}
stage('Test'){
steps{
echo 'Testing the project'
echo 'All Test cases passed'
// sh 'npm test'
}
}
stage('Build Image'){
steps{
echo 'Building the docker image'
sh 'docker build -t nirmalyamondal/react:latestdevops .'
}
}
stage('Push Image'){
steps{
echo 'Pushing the docker image'
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]){
sh 'docker login -u $USERNAME -p $PASSWORD'
sh 'docker push nirmalyamondal/react:latestdevops'
}
}
}
stage('Deploy'){
steps{
echo 'Deploying the docker image'
sh 'docker run -d -p 3000:3000 nirmalyamondal/react:latestdevops'
}
}
}
}