-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
42 lines (41 loc) · 2.18 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
pipeline {
agent any
environment {
AWS_ACCESS_KEY = credentials('accesskey')
AWS_SECRET_KEY = credentials('secretkey')
AWS_KEY = credentials('aws')
DOCKER = credentials('Docker')
}
stages {
stage('Test') {
steps {
echo "----------------------------------------------TEST----------------------------------------------"
sh 'mkdir project'
dir('project') {
git branch: 'main', url: 'git@github.com:Rolika4/Real_World.git', credentialsId: 'github_key'
}
sh 'sleep 5'
echo "----------------------------------------------PASS----------------------------------------------"
}
}
stage('Build') {
steps {
echo "----------------------------------------------BUILD----------------------------------------------"
sh 'terraform -chdir=build init'
sh 'terraform -chdir=build apply -auto-approve -var="key=$AWS_KEY" -var="accesskey=$AWS_ACCESS_KEY" -var="secretkey=$AWS_SECRET_KEY" -var="DockerLogin=$DOCKER_USR" -var="DockerPsw=$DOCKER_PSW"'
sh 'terraform -chdir=build destroy -auto-approve -var="accesskey=$AWS_ACCESS_KEY" -var="secretkey=$AWS_SECRET_KEY" '
echo "----------------------------------------------PASS-----------------------------------------------"
}
}
stage('Deployy') {
steps {
echo "----------------------------------------------DEPLOY----------------------------------------------"
sh 'terraform -chdir=deploy init'
sh 'terraform -chdir=deploy apply -auto-approve -var="key=$AWS_KEY" -var="accesskey=$AWS_ACCESS_KEY" -var="secretkey=$AWS_SECRET_KEY" -var="DockerLogin=$DOCKER_USR" -var="DockerPsw=$DOCKER_PSW"'
sh 'terraform -chdir=deploy destroy -auto-approve -var="accesskey=$AWS_ACCESS_KEY" -var="secretkey=$AWS_SECRET_KEY" '
echo "----------------------------------------------PASS------------------------------------------------"
cleanWs()
}
}
}
}