-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
58 lines (56 loc) · 1.7 KB
/
Jenkinsfile
File metadata and controls
58 lines (56 loc) · 1.7 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
56
57
58
// this file needed when you using Jenkins in your development process for CI/CD
pipeline{
agent any
tools {
nodejs "node-"
git "git-"
}
stages{
stage("checkout"){
steps{
checkout scm
}
}
// stage("Test"){
// steps{
// sh 'npm install'
// sh 'npm test'
// }
// }
stage("install dependencies"){
steps{
sh 'npm install'
}
}
stage("Build"){
steps{
sh 'npm run build'
}
}
stage("Build Image"){
steps{
sh 'docker build -t digital-archiving-frontend:${BUILD_NUMBER} .'
}
}
stage("Docker Push to Nexus"){
steps{
withCredentials([usernamePassword(credentialsId: 'nexus', passwordVariable: 'PSW', usernameVariable: 'USER')]){
sh 'echo ${PSW} | docker login -u ${USER} --password-stdin 100.102.123.78:8085'
sh 'docker push digital-archiving-frontend:${BUILD_NUMBER}'
sh 'docker logout'
}
}
}
stage("Docker Pull & Run Image"){
steps{
script {
sshagent(['ssh-staging']) {
sh "ssh [email protected]"
sh "docker pull digital-archiving-frontend:${BUILD_NUMBER}"
sh "docker run -d --name digital-archiving -p 5000:3000 --restart=always digital-archiving-frontend:${BUILD_NUMBER}"
}
}
}
}
}
}