forked from jenkins-x/jx-convert-jenkinsfile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
60 lines (52 loc) · 1.45 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
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
environment {
SOURCECODE_JENKINS_CREDENTIAL_ID = 'jenking-github-wh'
SOURCE_CODE_URL = 'https://github.com/my-research/todo-with-cicd.git'
RELEASE_BRANCH = 'master'
}
stages {
stage('Init') {
steps {
echo 'clear'
sh 'docker stop $(docker ps -aq)'
sh 'docker rm $(docker ps -aq)'
deleteDir()
}
}
stage('clone') {
steps {
git url: "$SOURCE_CODE_URL",
branch: "$RELEASE_BRANCH",
credentialsId: "$SOURCECODE_JENKINS_CREDENTIAL_ID"
sh "ls -al"
}
}
stage('frontend dockerizing') {
steps {
sh "docker build -t todo/frontend ./frontend"
}
}
stage('backend dockerizing') {
steps {
sh "pwd"
dir("./backend"){
sh "pwd"
sh "gradle clean"
sh "gradle bootJar"
sh "docker build -t todo/backend ."
}
}
}
stage('deploy') {
steps {
sh '''
docker run -d -p 5000:5000 todo/frontend
docker run -d -p 8080:8080 todo/backend
'''
}
}
}
}