-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
136 lines (97 loc) · 5.15 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
pipeline {
agent any
stages {
stage('clearing out old workspace'){
steps{
deleteDir()
}
}
//Print Params
stage('Current Directory') {
steps {
echo pwd
}
}
stage('Git Checkout setup') {
steps {
git branch: "main",
credentialsId: 'git',
url: 'https://github.com/ipsgit2018/testing.git'
}
}
stage('Create Source artifactory')
{
steps {
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'ansible_ssh_id', keyFileVariable: 'ANSIBLE_KEY', passphraseVariable: '', usernameVariable: 'ANSIBLE_USER')])
{
sh """#!/bin/bash
export ANSIBLE_HOST_KEY_CHECKING=False
pwd
cd $WORKSPACE
#ansible-playbook -vv copy_source.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY
#ansible-playbook -vv replace.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY --extra-vars Application_Name=$Application_Name --extra-vars Source_Environment=$Source_Environment --extra-vars FilePath_Name=$Export_File_Name --extra-vars Control_File=$Control_File --extra-vars Target_Environment=$Target_Environment --extra-vars Project_Name=$Project_Name
"""
}
}
}
stage('Create pratik exports')
{
steps {
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'ansible_ssh_id', keyFileVariable: 'ANSIBLE_KEY', passphraseVariable: '', usernameVariable: 'ANSIBLE_USER')])
{
sh """#!/bin/bash
export ANSIBLE_HOST_KEY_CHECKING=False
pwd
cd $WORKSPACE
#ansible-playbook -vv /tmp/jenkins/export_control.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY
"""
}
}
}
stage('Create pratik imports')
{
steps {
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'ansible_ssh_id', keyFileVariable: 'ANSIBLE_KEY', passphraseVariable: '', usernameVariable: 'ANSIBLE_USER')])
{
sh """#!/bin/bash
export ANSIBLE_HOST_KEY_CHECKING=False
#ansible-playbook -vv /tmp/jenkins/replace_import.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY --extra-vars Application_Name=$Application_Name --extra-vars Source_Environment=$Source_Environment --extra-vars FilePath_Name=$Export_File_Name --extra-vars Control_File=$Import_Control_File --extra-vars Target_Environment=$Target_Environment
#ansible-playbook -vv /tmp/jenkins/import_infa.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY
"""
}
}
}
stage('Unit Testing')
{
steps {
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'ansible_ssh_id', keyFileVariable: 'ANSIBLE_KEY', passphraseVariable: '', usernameVariable: 'ANSIBLE_USER')])
{
sh """#!/bin/bash
export ANSIBLE_HOST_KEY_CHECKING=False
#ansible-playbook -vv /tmp/jenkins/replace_import.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY --extra-vars Application_Name=$Application_Name --extra-vars Source_Environment=$Source_Environment --extra-vars FilePath_Name=$Export_File_Name --extra-vars Control_File=$Import_Control_File --extra-vars Target_Environment=$Target_Environment
#ansible-playbook -vv /tmp/jenkins/import_infa.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY
"""
}
}
}
stage('Deploy to Environment??')
{
steps {
input("Deploy to Prod ?")
}
}
stage('Deploy to Integration service')
{
steps {
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'ansible_ssh_id', keyFileVariable: 'ANSIBLE_KEY', passphraseVariable: '', usernameVariable: 'ANSIBLE_USER')])
{
sh """#!/bin/bash
export ANSIBLE_HOST_KEY_CHECKING=False
#ansible-playbook -vv /tmp/jenkins/replace_application.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY --extra-vars Application_Name=$Application_Name --extra-vars Project_Name=$Project_Name --extra-vars Integration_Service=$Integration_Service --extra-vars Target_Environment=$Target_Environment
#ansible-playbook -vv /tmp/jenkins/create_war_app.yaml --extra-vars ansible_user=pratik --extra-vars ansible_ssh_private_key_file=$ANSIBLE_KEY
"""
}
}
}
}
}