-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsFile.Ref
More file actions
122 lines (113 loc) · 3.18 KB
/
JenkinsFile.Ref
File metadata and controls
122 lines (113 loc) · 3.18 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
pipeline
{
parameters
{
string(name: "authenticationDomain" , defaultValue : 'app.geeks.ltd')
string(name: "ecrAddress", defaultValue: '669486994886.dkr.ecr.eu-west-1.amazonaws.com')
string(name: "region", defaultValue: 'eu-west-1')
string(name: "k8sSSHServer" , defaultValue : 'https://api.app.geeks.ltd')
string(name: "privateRepositoryAddress" , defaultValue : 'http://nuget.geeksms.uat.co/nuget')
booleanParam(name: "Rebuild" , defaultValue : false)
}
environment
{
IMAGE = 'geeksms-hub'
REGION_NAME = "${params.region}"
ECR_URL = "https://${params.ecrAddress}"
ECR_CRED = credentials('ECRCRED')
BUILD_VERSION="v_${BUILD_NUMBER}"
ECR_IMAGE_URL = "${params.ecrAddress}/${IMAGE}:${BUILD_VERSION}"
AWS_CREDENTIALS_ID = 'JenkinsECRAWSCredentials'
GIT_REPOSITORY = 'git@gitlab.com:Geeks.Microservices/AccessHub.git'
GIT_CREDENTIALS_ID = '1ef3615c-8221-4d33-af6d-91b203d60c75'
BUILD_VERION_NUMBER = '0'
K8S_SSH_SERVER = "${params.k8sSSHServer}"
K8S_DEPLOYMENT_TEMPLATE = ".\\DevOps\\Kubernetes\\Deployment.yaml"
K8S_LATEST_CONFIG_FILE = "DevOps/Kubernetes/Deployment.yaml"
PRIVATE_REPOSITORY_ADDRESS = "${params.privateRepositoryAddress}"
PRIVATE_REPOSITORY_ADDRESS_NAME = "GeeksMS"
AUTHENTICATION_DOMAIN = "${params.authenticationDomain}"
HUB_SERVICE_URL = "https://hub.app.geeks.ltd"
}
agent any
stages{
stage('Clone sources')
{
steps
{
script
{
git url: GIT_REPOSITORY
}
}
}
stage('Get secure info')
{
steps
{
script
{
echo "Update the application version"
bat ''' TODO '''
}
}
}
stage('Push to ECR (on linux)')
{
steps
{
script
{
docker.withRegistry(ECR_URL, ECR_CRED)
{
docker.image(IMAGE).push(BUILD_VERSION)
}
}
}
}
stage('Update the K8s deployment file')
{
steps
{
script
{
bat ''' replace-in-file %K8S_DEPLOYMENT_TEMPLATE% -set "%%DOCKER_IMAGE%%" %ECR_IMAGE_URL% -set "%%BUILD_VERSION%%" %BUILD_VERSION% '''
}
}
}
stage('Deploy to cluster')
{
steps
{
script
{
bat ''' kubectl apply -f Deployment.yaml '''
}
}
}
}
post
{
failure
{
script
{
echo 'Failed to deploy HUB to production'
}
}
success
{
script
{
echo 'Deployed HUB to production'
}
}
always
{
script{
// make sure that the Docker image is removed
sh '''docker rmi $IMAGE | true'''
}
}
}
}