-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsychronizeFeatureBranch_pipeline.yml
134 lines (112 loc) · 4.2 KB
/
sychronizeFeatureBranch_pipeline.yml
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
# Export workflow pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger: none
variables:
- group: webMethodsIO_group
- group: github_group
- name: repoPath
value: $(gitOwner)/$(repoName)
pool:
vmImage: ubuntu-latest
resources:
repositories:
- repository: projectRepo
type: github
endpoint: github
name: $(repoPath)
ref: $(featureBranchName)
steps:
- checkout: projectRepo
submodules: "true"
persistCredentials: "true"
clean: "true"
path: $(repoName)
- checkout: self
submodules: "true"
persistCredentials: "true"
clean: "true"
path: self
- script: |
echo "##vso[task.setvariable variable=assetID;]NA"
echo "##vso[task.setvariable variable=assetType;]NA"
echo "##vso[task.setvariable variable=assetName;]NA"
condition: eq(variables['synchProject'], 'true')
displayName: 'Adjust variables'
- bash: |
pwd
cd ../self
pwd
ls -ltr
echo "##vso[task.setvariable variable=source_environment_hostname]`yq -e ".tenant.hostname" configs/env/play.yml`"
echo "##vso[task.setvariable variable=source_environment_port]`yq -e ".tenant.port" configs/env/play.yml`"
echo "##vso[task.setvariable variable=admin_user]`yq -e ".tenant.admin_username" configs/env/play.yml`"
echo "##vso[task.setvariable variable=source_type]`yq -e ".tenant.type" configs/env/play.yml`"
PROJECTNAME=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$(repoName)")
#echo ${PROJECTNAME}
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber)-${PROJECTNAME}"
echo $(System.DefaultWorkingDirectory)
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Get Environment Tenant Details'
- script: |
#echo $(source_environment_hostname)
#echo $(source_environment_port)
#echo $(admin_user)
#echo $(source_type)
repoName=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$(repoName)")
#echo $(repoName)
LOCAL_DEV_URL=https://$(source_environment_hostname):$(source_environment_port)
#echo ${LOCAL_DEV_URL}
HOME_DIR=$(System.DefaultWorkingDirectory)/../
cd $(System.DefaultWorkingDirectory)/../
cd $(repoName)
chmod +x ../self/pipelines/scripts/*.sh
config_dir=${HOME_DIR}self/configs/env
###### Fetching Environments
echo "Fetching Environment Types ..."
envTypes=$(../self/pipelines/scripts/readEnvs.sh ${config_dir} $(source_type))
echo "****Envs****: "$envTypes
###### Exporting
echo "Exporting asset ..."
../self/pipelines/scripts/exportAsset.sh ${LOCAL_DEV_URL} $(admin_user) $(admin_password) $(repoName) $(assetID) $(assetType) ${HOME_DIR} $(synchProject) $(source_type) $(inlcudeAllReferenceData) ${envTypes} debug
displayName: 'Export Asset'
#failOnStderr: true
- script: |
cd ../$(repoName)
echo "Committing asset ..."
chmod +x ../self/pipelines/scripts/github/*.sh
../self/pipelines/scripts/github/commitFeatureBranch.sh $(devUser) $(Build.BuildNumber) $(featureBranchName) ${HOME_DIR} debug
displayName: 'Commit the code to feature branch'
- script: |
cd ../$(repoName)
FILE="./resources/test/environments/$(source_type).json"
fileExists=false
if test -f "$FILE"; then
echo "$FILE exists."
fileExists=true
fi
echo "##vso[task.setvariable variable=FileExists]$fileExists"
displayName: 'Evaluate if Test Assets Exists'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(System.DefaultWorkingDirectory)/../$(repoName)'
artifactName: '$(repoName)_export'
displayName: 'Publishing the export'
- task: DeleteFiles@1
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)../$(repoName)'
Contents: './*'
displayName: 'Remove the Export after successfull Commit'
- task: TriggerBuild@4
inputs:
buildDefinition: 'Test'
useSameBranch: true
storeInEnvironmentVariable: true
authenticationMethod: 'OAuth Token'
password: $(System.AccessToken)
buildParameters:
'repoName:$(repoName), branch:$(featureBranchName), environment:$(source_type)'
displayName: Trigger Test Pipeline
continueOnError: false
condition: eq(variables['FileExists'], True)