-
Notifications
You must be signed in to change notification settings - Fork 5
/
jenkinsfile
56 lines (47 loc) · 2.04 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
/* pipeline 변수 설정 */
def app
node {
// github 로부터 소스코드 다운로드
stage('Checkout') {
checkout scm
}
// mvn 툴 선언하는 stage, 필자의 경우 maven 3.6.0을 사용중
stage('Ready'){
sh "echo 'Ready to build'"
}
//dockerfile기반 빌드하는 stage ,git소스 root에 dockerfile이 있어야한다
stage('Build image'){
app = docker.build("harbor.cu.ac.kr/dcucode/dcu_code_fe")
sh """
docker run --name sample -d -u root harbor.cu.ac.kr/dcucode/dcu_code_fe
docker cp sample:/oj_frontend/dist .
docker rm -f sample
"""
sh "ls -al"
sh "ls -al dist"
sh '''
tar czvf latest.tar.gz -C dist .
cp latest.tar.gz build_${BUILD_NUMBER}.tar.gz
pwd
ls -al
'''
}
stage("Publish on SSH") {
sshPublisher(publishers: [sshPublisherDesc(configName: 'snslab_ssh', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '/static_files/dcucode', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '*.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true)])
}
//docker image를 push하는 stage, 필자는 dockerhub에 이미지를 올렸으나 보통 private image repo를 별도 구축해서 사용하는것이 좋음
//docker.withRegistry에 dockerhub는 앞서 설정한 dockerhub credentials의 ID이다.
//stage('Push image') {
// docker.withRegistry("https://harbor.cu.ac.kr", "harbor") {
// app.push("latest")
// app.push("${env.BUILD_NUMBER}")
// }
//}
//stage('Kubernetes deploy') {
// sh "kubectl delete -f /services/dcucode/oj-frontend_only_con.yaml -n dcucode"
// sh "kubectl apply -f /services/dcucode/oj-frontend_only_con.yaml -n dcucode"
//}
stage('Complete') {
sh "echo 'The end'"
}
}