-
Notifications
You must be signed in to change notification settings - Fork 0
/
awsJenkinsFile
59 lines (53 loc) · 1.34 KB
/
awsJenkinsFile
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
pipeline {
agent any
environment {
AWS_ACCOUNT_ID="694052011150"
AWS_DEFAULT_REGION="us-east-1c"
CLUSTER_NAME="azmassger_gateway"
SERVICE_NAME="CHANGE_ME"
TASK_DEFINITION_NAME="CHANGE_ME"
DESIRED_COUNT="CHANGE_ME"
IMAGE_REPO_NAME="test"
IMAGE_TAG="${env.BUILD_ID}"
REPOSITORY_URI = "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_REPO_NAME}"
registryCredential = "CHANGE_ME"
}
stages {
// Tests
stage('Unit Tests') {
steps{
script {
sh 'npm install'
sh 'npm test -- --watchAll=false'
}
}
}
// Building Docker images
stage('Building image') {
steps{
script {
dockerImage = docker.build "${IMAGE_REPO_NAME}:${IMAGE_TAG}"
}
}
}
// Uploading Docker images into AWS ECR
stage('Pushing to ECR') {
steps{
script {
docker.withRegistry("https://" + REPOSITORY_URI, "ecr:${AWS_DEFAULT_REGION}:" + registryCredential) {
dockerImage.push()
}
}
}
}
stage('Deploy') {
steps{
withAWS(credentials: registryCredential, region: "${AWS_DEFAULT_REGION}") {
script {
sh './script.sh'
}
}
}
}
}
}