-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1New_Replace
97 lines (88 loc) · 4.86 KB
/
1New_Replace
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
pipeline {
agent any
parameters {
booleanParam(name: 'Activate_Integration', defaultValue: false, description: 'Check the box if you want Activate the integration after importing')
}
stages {
stage('Import Integration') {
steps {
script {
def selectedOption = "${params.Import_Method}".trim()
if (selectedOption == 'New') {
echo 'Adding new integration'
def integURL=(params.InstanceURL).toString()+"/ic/api/integration/v1/integrations/archive"
def deployIntegCmd = "curl --location \"${integURL}\" --silent --user ${params.Username}:${params.Password} --form \"file=@\\\"${params.IARFileName}\\\"\""
bat(deployIntegCmd)
} else if (selectedOption == 'Replace') {
echo 'Replacing an integration'
def updateIntegFileCmd = "curl -X PUT --user ${params.Username}:${params.Password} --header \"Accept:application/json\" --form \"file=@\\\"${params.IARFileName}\\\"\" --form type=application/octet-stream ${params.InstanceURL}/ic/api/integration/v1/integrations/archive"
bat(updateIntegFileCmd)
} else{
echo 'No import method is selected'
}
}
}
}
stage('Import Connection') {
steps {
script {
def selectedOption = "${params.Import_Method}".trim()
if (selectedOption == 'New') {
echo 'Adding new connection'
bat """
curl --user ${params.Username}:${params.Password} --header "X-HTTP-Method-Override:PATCH" --header "Content-Type:application/json" -d @${params.ConnectionFileName} ${params.InstanceURL}/ic/api/integration/v1/connections/${params.ConnectionName}
"""
} else if (selectedOption == 'Replace') {
echo 'Replacing a connection'
bat"""
curl --user ${params.Username}:${params.Password} --header "X-HTTP-Method-Override:PATCH" --header "Content-Type:application/json" -d @${params.ConnectionFileName} ${params.InstanceURL}/ic/api/integration/v1/connections/${params.ConnectionName}
"""
} else{
echo 'No import method is selected'
}
}
}
}
stage('Import Lookup') {
steps {
script {
def selectedOption = "${params.Import_Method}".trim()
if (selectedOption == 'New') {
echo 'Adding new lookup'
def configLookupCmd = "curl -X POST --user ${params.Username}:${params.Password} -F \"file=@${params.LookupFileName}\" -F \"type=application/octet-stream\" ${params.InstanceURL}/ic/api/integration/v1/lookups/archive"
bat(configLookupCmd)
} else if (selectedOption == 'Replace') {
echo 'Replacing a lookup'
def updateLookupCmd = "curl -X PUT --user ${params.Username}:${params.Password} -F \"file=@${params.LookupFileName}\" -F type=application/octet-stream \"${params.InstanceURL}/ic/api/integration/v1/lookups/archive\""
bat(updateLookupCmd)
} else{
echo 'No import method is selected'
}
}
}
}
// Add other stages as needed
stage('Activation of Integration') {
steps {
script {
def integName = params.Integration_Identifier.toString()
if (params.Activate_Integration) {
// Perform action when the checkbox is checked
echo 'Checkbox is checked'
def activateIntegrationCmd = "curl --user ${params.Username}:${params.Password} --header \"Content-Type: application/json\" --header \"X-HTTP-Method-Override: PATCH\" -d @${params.ActivationJsonFile} --location \"${params.InstanceURL}/ic/api/integration/v1/integrations/${integName}\""
bat(activateIntegrationCmd)
echo "Integration Activated"
// Add your desired logic here
} else {
// Perform a different action when the checkbox is not checked
echo 'Checkbox is not checked'
// Add your desired logic here
def deactivateIntegrationCmd = "curl --user ${params.Username}:${params.Password} --header \"Content-Type: application/json\" --header \"X-HTTP-Method-Override: PATCH\" -d @${params.DeactivationJsonFile} -d 'enableAsyncActivationMode=true' \"${params.InstanceURL}/ic/api/integration/v1/integrations/${integName}\""
bat(deactivateIntegrationCmd)
echo "Integration Configured"
}
}
}
}
}
}