Skip to content

Commit 9220526

Browse files
author
insrsa
committed
1. External Test Credentials from post environment files
2. Project ID fix: Create a temp flow to export import project to maintain id in all environment.
1 parent 6c81c9f commit 9220526

File tree

5 files changed

+314
-3
lines changed

5 files changed

+314
-3
lines changed

Release.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
##### November 2023 Release ########
66
1. Public Apis for Reference Data
77
2. Github action using HTTP/REST
8-
3. Bug fixes
8+
3. Bug fixes
9+
##### January 2024 Release ########
10+
1. External Test Credentials from post environment files
11+
2. Project ID fix: Create a temp flow to export import project to maintain id in all environment.

pipelines/InitiateTesting.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ trigger:
1313

1414
variables:
1515
- group: github_group
16+
- group: webMethodsIO_group
1617
- name: repoPath
1718
value: $(gitOwner)/$(repoName)
1819

@@ -46,6 +47,11 @@ steps:
4647
cd $(repoName)
4748
fi
4849
echo "##vso[task.setvariable variable=source_type]${source}"
50+
cd ../self
51+
pwd
52+
ls -ltr
53+
echo "##vso[task.setvariable variable=admin_user]`yq -e ".tenant.admin_username" configs/${source}.yml`"
54+
4955
echo $(System.DefaultWorkingDirectory)
5056
workingDirectory: '$(System.DefaultWorkingDirectory)'
5157
displayName: 'Get Environment Tenant Details'
@@ -54,10 +60,11 @@ steps:
5460
cd ../$(repoName)
5561
pwd
5662
echo $(source_type)
57-
echo "newman run ./resources/test/wmio_test.json -e ./resources/test/environments/$(source_type).json --env-var "project=$(repoName)" --reporters cli,junit --reporter-junit-export $(System.DefaultWorkingDirectory)/$(source_type)/results/junitReport.xml
63+
echo $(admin_user)
64+
echo "newman run ./resources/test/wmio_test.json -e ./resources/test/environments/$(source_type).json --env-var "project=$(repoName)" --env-var "user=$(admin_user)" --env-var "password=$(admin_password)" --reporters cli,junit --reporter-junit-export $(System.DefaultWorkingDirectory)/$(source_type)/results/junitReport.xml
5865
ls -ltr $(System.DefaultWorkingDirectory)/$(source_type)/results/"
5966
60-
newman run ./resources/test/wmio_test.json -e ./resources/test/environments/$(source_type).json --env-var "project=$(repoName)" --reporters cli,junit --reporter-junit-export $(System.DefaultWorkingDirectory)/$(source_type)/results/junitReport.xml
67+
newman run ./resources/test/wmio_test.json -e ./resources/test/environments/$(source_type).json --env-var "project=$(repoName)" --env-var "user=$(admin_user)" --env-var "password=$(admin_password)" --reporters cli,junit --reporter-junit-export $(System.DefaultWorkingDirectory)/$(source_type)/results/junitReport.xml
6168
ls -ltr $(System.DefaultWorkingDirectory)/$(source_type)/results/
6269
displayName: 'Run newman'
6370
- task: PublishTestResults@2

pipelines/initialize_pipeline.yml

+42
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ steps:
5656
echo "##vso[task.setvariable variable=admin_user]`yq -e ".tenant.admin_username" configs/play.yml`"
5757
echo "##vso[task.setvariable variable=source_type]`yq -e ".tenant.type" configs/play.yml`"
5858
echo "##vso[task.setvariable variable=repo_user]`yq -e ".repo.user" configs/repo.yml`"
59+
60+
echo "##vso[task.setvariable variable=dev_environment_hostname]`yq -e ".tenant.hostname" configs/dev.yml`"
61+
echo "##vso[task.setvariable variable=dev_environment_port]`yq -e ".tenant.port" configs/dev.yml`"
62+
echo "##vso[task.setvariable variable=dev_admin_user]`yq -e ".tenant.admin_username" configs/dev.yml`"
63+
64+
echo "##vso[task.setvariable variable=qa_environment_hostname]`yq -e ".tenant.hostname" configs/qa.yml`"
65+
echo "##vso[task.setvariable variable=qa_environment_port]`yq -e ".tenant.port" configs/qa.yml`"
66+
echo "##vso[task.setvariable variable=qa_admin_user]`yq -e ".tenant.admin_username" configs/qa.yml`"
67+
68+
echo "##vso[task.setvariable variable=prod_environment_hostname]`yq -e ".tenant.hostname" configs/prod.yml`"
69+
echo "##vso[task.setvariable variable=prod_environment_port]`yq -e ".tenant.port" configs/prod.yml`"
70+
echo "##vso[task.setvariable variable=prod_admin_user]`yq -e ".tenant.admin_username" configs/prod.yml`"
71+
5972
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber)-$(repoName)"
6073
echo $(System.DefaultWorkingDirectory)
6174
workingDirectory: '$(System.DefaultWorkingDirectory)'
@@ -96,6 +109,35 @@ steps:
96109
chmod +x ./self/pipelines/scripts/*.sh
97110
./self/pipelines/scripts/createProject.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName)
98111
112+
echo "PROJECT ID TEMP FIX: Importing dummy flowservice ..."
113+
mkdir -p ${HOME_DIR}/$(repoName)/assets/flowservices/
114+
cp ./self/assets/flowservices/SampleFlowService.zip ${HOME_DIR}/$(repoName)/assets/flowservices/
115+
116+
./self/pipelines/scripts/importAsset.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName) "SampleFlowService" "flowservice" ${HOME_DIR} "false" $(source_type) debug
117+
118+
echo "PROJECT ID TEMP FIX: Publishing & Deploying Project DEV..."
119+
./self/pipelines/scripts/replicateProject.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName) $(dev_environment_hostname) $(dev_environment_port) $(dev_admin_user) "SampleFlowService" debug
120+
LOCAL_DEVE_URL=https://$(dev_environment_hostname):$(dev_environment_port)
121+
echo "PROJECT ID TEMP FIX: Deleting dummy flowservice DEV..."
122+
./self/pipelines/scripts/deleteAssets.sh ${LOCAL_DEVE_URL} $(dev_admin_user) $(admin_password) $(repoName) "SampleFlowService" "flowservice" "false" debug
123+
124+
echo "PROJECT ID TEMP FIX: Publishing & Deploying Project QA..."
125+
./self/pipelines/scripts/replicateProject.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName) $(qa_environment_hostname) $(qa_environment_port) $(qa_admin_user) "SampleFlowService" debug
126+
LOCAL_QA_URL=https://$(qa_environment_hostname):$(qa_environment_port)
127+
echo "PROJECT ID TEMP FIX: Deleting dummy flowservice QA..."
128+
./self/pipelines/scripts/deleteAssets.sh ${LOCAL_QA_URL} $(qa_admin_user) $(admin_password) $(repoName) "SampleFlowService" "flowservice" "false" debug
129+
130+
131+
echo "PROJECT ID TEMP FIX: Publishing & Deploying Project PROD..."
132+
./self/pipelines/scripts/replicateProject.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName) $(prod_environment_hostname) $(prod_environment_port) $(prod_admin_user) "SampleFlowService" debug
133+
LOCAL_PROD_URL=https://$(prod_environment_hostname):$(prod_environment_port)
134+
echo "PROJECT ID TEMP FIX: Deleting dummy flowservice PROD..."
135+
./self/pipelines/scripts/deleteAssets.sh ${LOCAL_PROD_URL} $(prod_admin_user) $(admin_password) $(repoName) "SampleFlowService" "flowservice" "false" debug
136+
137+
echo "PROJECT ID TEMP FIX: Deleting dummy flowservice PLAY..."
138+
./self/pipelines/scripts/deleteAssets.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName) "SampleFlowService" "flowservice" "false" debug
139+
140+
99141
else
100142
######## Create a feature branch from prod
101143
echo "Repo Exists, Check and sync feature branch from Prod"

pipelines/scripts/deleteAssets.sh

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
3+
#############################################################################
4+
# #
5+
# replicateProject.sh : Publish & Deploy Project to maintain same id #
6+
# #
7+
#############################################################################
8+
9+
LOCAL_DEV_URL=$1
10+
admin_user=$2
11+
admin_password=$3
12+
repoName=$4
13+
assetID=$5
14+
assetType=$6
15+
deleteProject=$7
16+
debug=${@: -1}
17+
18+
if [ -z "$LOCAL_DEV_URL" ]; then
19+
echo "Missing template parameter LOCAL_DEV_URL"
20+
exit 1
21+
fi
22+
23+
if [ -z "$admin_user" ]; then
24+
echo "Missing template parameter admin_user"
25+
exit 1
26+
fi
27+
28+
if [ -z "$admin_password" ]; then
29+
echo "Missing template parameter admin_password"
30+
exit 1
31+
fi
32+
33+
if [ -z "$repoName" ]; then
34+
echo "Missing template parameter repoName"
35+
exit 1
36+
fi
37+
if [ -z "$assetType" ]; then
38+
echo "Missing template parameter assetType"
39+
exit 1
40+
fi
41+
if [ -z "$deleteProject" ]; then
42+
echo "Missing template parameter deleteProject"
43+
exit 1
44+
fi
45+
if [ -z "$assetID" ]; then
46+
echo "Missing template parameter destEnv"
47+
exit 1
48+
fi
49+
if [ "$debug" == "debug" ]; then
50+
echo "......Running in Debug mode ......"
51+
fi
52+
53+
54+
function echod(){
55+
56+
if [ "$debug" == "debug" ]; then
57+
echo $1
58+
set -x
59+
fi
60+
61+
}
62+
63+
function deleteAsset(){
64+
65+
LOCAL_DEV_URL=$1
66+
admin_user=$2
67+
admin_password=$3
68+
repoName=$4
69+
assetID=$5
70+
assetType=$6
71+
72+
73+
74+
if [[ $assetType = workflow* ]]; then
75+
echod $assetType
76+
DELETE_URL=${LOCAL_DEV_URL}/apis/v1/rest/projects/${repoName}/workflows/${assetID}
77+
echod "Workflow Delete:" ${DELETE_URL}
78+
else
79+
if [[ $assetType = flowservice* ]]; then
80+
DELETE_URL=${LOCAL_DEV_URL}/apis/v1/rest/projects/${repoName}/flows/${assetID}
81+
echod "Flowservice Delete:" ${DELETE_URL}
82+
fi
83+
fi
84+
85+
echo "Deleting "${assetType}" in project: "${repoName}
86+
87+
deleteJson=$(curl --location --request DELETE ${DELETE_URL} \
88+
--header 'Content-Type: application/json' \
89+
--header 'Accept: application/json' \
90+
-u ${admin_user}:${admin_password} | jq -r '.output.message // empty')
91+
92+
echod ${deleteJson}
93+
94+
}
95+
96+
97+
if [ ${deleteProject} == true ]; then
98+
echo "Listing All Assets"
99+
100+
PROJECT_LIST_URL=${LOCAL_DEV_URL}/apis/v1/rest/projects/${repoName}/assets
101+
echo "Listing assets in project ... "
102+
103+
projectListJson=$(curl --location --request GET ${PROJECT_LIST_URL} \
104+
--header 'Content-Type: application/json' \
105+
--header 'Accept: application/json' \
106+
-u ${admin_user}:${admin_password})
107+
108+
echod ${projectListJson}
109+
110+
111+
# Deleting Workflows
112+
for item in $(jq -c -r '.output.workflows[]' <<< "$projectListJson"); do
113+
echod "Inside Workflow Loop"
114+
assetID=$item
115+
assetType=workflow
116+
echod $assetID
117+
deleteAsset ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} workflow
118+
done
119+
120+
echo "Listing assets in project ... "
121+
projectListJson=$(curl --location --request GET ${PROJECT_LIST_URL} \
122+
--header 'Content-Type: application/json' \
123+
--header 'Accept: application/json' \
124+
-u ${admin_user}:${admin_password})
125+
126+
echod ${projectListJson}
127+
128+
# Deleting Flows
129+
for item in $(jq -c -r '.output.flows[]' <<< "$projectListJson"); do
130+
echod "Inside FS Loop"
131+
assetID=$item
132+
assetType=flowservice
133+
echod $assetID
134+
deleteAsset ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} flowservice
135+
done
136+
else
137+
echod "Single asset delete ..."
138+
deleteAsset ${LOCAL_DEV_URL} ${admin_user} ${admin_password} ${repoName} ${assetID} ${assetType}
139+
fi
140+
141+
142+
set +x
143+
144+

pipelines/scripts/replicateProject.sh

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/bin/bash
2+
3+
#############################################################################
4+
# #
5+
# replicateProject.sh : Publish & Deploy Project to maintain same id #
6+
# #
7+
#############################################################################
8+
9+
LOCAL_DEV_URL=$1
10+
admin_user=$2
11+
admin_password=$3
12+
repoName=$4
13+
destEnv=$5
14+
destPort=$6
15+
destUser=$7
16+
assetID=$8
17+
debug=${@: -1}
18+
19+
if [ -z "$LOCAL_DEV_URL" ]; then
20+
echo "Missing template parameter LOCAL_DEV_URL"
21+
exit 1
22+
fi
23+
24+
if [ -z "$admin_user" ]; then
25+
echo "Missing template parameter admin_user"
26+
exit 1
27+
fi
28+
29+
if [ -z "$admin_password" ]; then
30+
echo "Missing template parameter admin_password"
31+
exit 1
32+
fi
33+
34+
if [ -z "$repoName" ]; then
35+
echo "Missing template parameter repoName"
36+
exit 1
37+
fi
38+
if [ -z "$destEnv" ]; then
39+
echo "Missing template parameter destEnv"
40+
exit 1
41+
fi
42+
if [ -z "$destPort" ]; then
43+
echo "Missing template parameter destEnv"
44+
exit 1
45+
fi
46+
if [ -z "$destUser" ]; then
47+
echo "Missing template parameter destEnv"
48+
exit 1
49+
fi
50+
if [ -z "$assetID" ]; then
51+
echo "Missing template parameter destEnv"
52+
exit 1
53+
fi
54+
if [ "$debug" == "debug" ]; then
55+
echo "......Running in Debug mode ......"
56+
fi
57+
58+
59+
function echod(){
60+
61+
if [ "$debug" == "debug" ]; then
62+
echo $1
63+
set -x
64+
fi
65+
66+
}
67+
68+
69+
70+
PROJECT_URL=${LOCAL_DEV_URL}/apis/v1/rest/projects/${repoName}/push
71+
echo "Publishing project ... "
72+
json='{ "name": "'${repoName}'", "description": "Dummy Synch", "destination_tenant_detail": { "username": "'${destUser}'","password": "'${admin_password}'", "url": "https://'${destEnv}':'${destPort}'"},"flows": ["'${assetID}'"]}'
73+
74+
75+
publishResponse=$(curl --location --request POST ${PROJECT_URL} \
76+
--header 'Content-Type: application/json' \
77+
--header 'Accept: application/json' \
78+
--data-raw "$json" -u ${admin_user}:${admin_password})
79+
80+
81+
82+
versioncreated=$(echo "$publishResponse" | jq '.output.version // empty')
83+
84+
if [ -z "$versioncreated" ]; then
85+
echo "Publish failed:" ${publishResponse}
86+
exit 1
87+
else
88+
echo "Publish Succeeded:" ${publishResponse}
89+
fi
90+
91+
LOCAL_DEV_URL=https://${destEnv}:${destPort}
92+
PROJECT_URL=${LOCAL_DEV_URL}/apis/v1/rest/projects/${repoName}/deploy
93+
94+
json='{ "version": "'${versioncreated}'"}'
95+
96+
echo "Deploying project ... "
97+
deployResponse=$(curl --location --request POST ${PROJECT_URL} \
98+
--header 'Content-Type: application/json' \
99+
--header 'Accept: application/json' \
100+
--data-raw "$json" -u ${destUser}:${admin_password})
101+
102+
103+
104+
deployCreated=$(echo "$deployResponse" | jq '.output.message // empty')
105+
106+
107+
if [ -z "$versioncreated" ]; then
108+
echo "Deploy failed:" ${deployResponse}
109+
exit 1
110+
else
111+
echo "Deploy Succeeded:" ${deployResponse}
112+
fi
113+
set +x
114+
115+

0 commit comments

Comments
 (0)