-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinfile.groovy
60 lines (53 loc) · 1.31 KB
/
Jenkinfile.groovy
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
def COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger']
pipeline {
agent any
options {
timestamps()
}
environment {
ANSIBLE_FORCE_COLOR = true
ANSIBLE_STDOUT_CALLBACK = "debug"
AWS_PROFILE="nfq-devops"
DEPLOY_HOST_TAG="migrate"
TIMESTAMP = """${sh(
returnStdout: true,
script: 'date --utc +%Y%m%d_%H%M%SZ'
).trim()}"""
}
parameters {
string (
defaultValue: "https://github.com/gsviec/demo-migrate.git",
description: "Repo to build",
name: "repo"
)
string (
defaultValue: "master",
description: "Branch to build",
name: "branch"
)
}
stages {
stage("Checkout SCM and Build") {
steps {
dir ("./app") {
git(
url: "${params.repo}",
credentialsId: "github",
branch: "${params.branch}",
changelog: true)
}
}
}
stage('Deploy') {
steps {
sh """
cd ./app
cp .env.prod .env
export ANSIBLE_CONFIG="./hostmap/ansible.cfg"
ansible-galaxy install -r hostmap/roles/requirements.yaml
ansible-playbook -i hostmap/inventory-tools.aws_ec2.yml deploy.yaml
"""
}
}
}
}