forked from genexuslabs/AzureDevOpsBuilding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContinuousBuildKb.yml
137 lines (113 loc) · 5.14 KB
/
ContinuousBuildKb.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
135
136
137
# Starter 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
variables:
#Pipeline config variables:
EXEC_AGENT: $(agent)
#Environment variables:
MSBUILD: $(msbuildpath)
BL_PATH: $(genexus)
WORKING_DIR: $(workingDir)
KB_PATH: $(workingDir)\$(kbalias)
#KB Building variables:
KB_ALIAS: $(kbalias)
GXSERVER_URL: $(serverurl)
GXSERVER_USER: $(serveruser)
GXSERVER_PASS: $(password)
KBENVIRONMENT: $(environment)
KBGENERATOR: $(generator)
FORCE_REBUILD: $(forceRebuild)
#Deploy variables:
PUBLISH_SETTINGS: $(azurePublish)
DEPLOYMENT_UNIT: $(deploymentUnit)
DEPLOY_NAME: $(deploymentUnit)$(Build.BuildNumber)
APPLICATION_KEY: $(encriptKey)
#Code versioning variables:
GIT_USER: $(gituser)
GIT_PASSWORD: $(gitpassword) #This could alternatively be a PAT
GIT_REPO: $(gitrepo)
GIT_BRANCH: $(gitbranch) #Branch must exist. Content will be overwritten
# Scheduled triggers. Can also be setup through UI, which takes precendence.
schedules:
- cron: "*/10 * * * *"
displayName: Custom time trigger
branches:
include:
- main
always: false
trigger:
- main
pool:
name: $(EXEC_AGENT)
jobs:
- job: CheckoutOrUpdate
condition: always()
steps:
- script: >
$(MSBUILD) "$(BL_PATH)\AzureCICD.msbuild" -target:CreateOrUpdateKB /p:WorkingDirectory=$(KB_PATH) /p:CreateDbInKbFolder=True
/p:DbaseName=$(KB_ALIAS) /p:DbaseUseIntegratedSecurity=True /p:ServerUrl=$(GXSERVER_URL) /p:ServerKbAlias=$(KB_ALIAS)
/p:ServerUsername=$(GXSERVER_USER) /p:ServerPassword=$(GXSERVER_PASS)
set /p updateCount=<"$(KB_PATH)\updateCount.txt"
echo ##vso[task.setvariable variable=updateCount;isOutput=true]%updateCount%
name: CreateOrUpdateKB
- job: BuildAndDeploy
dependsOn: CheckoutOrUpdate
condition: or(and(succeeded(), gt(dependencies.CheckoutOrUpdate.outputs['CreateOrUpdateKB.updateCount'], '0')),eq(variables['forceRebuild'], 'true'))
steps:
- script: rmdir $(KB_PATH)\NetModel /s /q
condition: eq(variables['forceRebuild'], 'true')
name: CleanBuildDir
- script: $(MSBUILD) "$(BL_PATH)\AzureCICD.Msbuild" -target:Build /p:WorkingDirectory=$(KB_PATH) /p:ForceRebuild=$(forceRebuild)
name: BuildKB
- script: >
$(MSBUILD) "$(BL_PATH)\deploy.msbuild" /t:CreateDeploy /p:KBPath=$(KB_PATH);KBEnvironment=$(KBENVIRONMENT);DeploymentUnit=$(DEPLOYMENT_UNIT)
/p:ProjectName=$(DEPLOY_NAME) /p:TargetId="AZURE" /p:ObjectNames="DeploymentUnitCategory:$(DEPLOYMENT_UNIT)"
/p:DEPLOY_TARGETS="$(BL_PATH)\DeploymentTargets\Azure\azure.targets"
/p:DeployFullPath="$(KB_PATH)\NetModel\Deploy\AZURE\$(DEPLOYMENT_UNIT)\$(DEPLOY_NAME)"
/p:WebSourcePath="$(KB_PATH)\NetModel\web" /p:GX_PROGRAM_DIR="$(BL_PATH)"
/p:AZURE_PUBLISH_SETTINGS="$(PUBLISH_SETTINGS)"
/p:APPLICATION_KEY="$(APPLICATION_KEY)"
name: CreateDeploy
- script: >
$(MSBUILD) /ToolsVersion:4.0 "$(KB_PATH)\NetModel\web\$(DEPLOY_NAME).gxdproj" /t:CreatePackage
/p:GX_PROGRAM_DIR="$(BL_PATH)" /p:AZURE_PUBLISH_SETTINGS="$(PUBLISH_SETTINGS)"
/p:APPLICATION_KEY="$(APPLICATION_KEY)"
name: CreatePackage
- script: >
$(MSBUILD) "$(BL_PATH)\DeploymentTargets\Azure\deploy.msbuild" /t:Deploy
/p:AZURE_PUBLISH_SETTINGS="$(PUBLISH_SETTINGS)"
/p:APPLICATION_KEY="$(APPLICATION_KEY)" /p:APPLICATION_NAME="$(DEPLOY_NAME)"
/p:DEPLOY_PATH="$(KB_PATH)\NetModel\Deploy\AZURE\$(DEPLOYMENT_UNIT)\$(DEPLOY_NAME)"
/p:GX_PROGRAM_DIR="$(BL_PATH)" /p:DeploySource="$(KB_PATH)\NetModel\Deploy\AZURE\$(DEPLOY_NAME).zip"
/p:CreateCloudPackage="false" /p:KBPath=$(KB_PATH) /p:KBEnvironment="$(KBENVIRONMENT)" /p:KBVersion="ActualizacionAmbiente2"
/p:DeploymentUnit="$(DEPLOYMENT_UNIT)" /p:ProjectName="$(DEPLOY_NAME)" /p:TargetId="AZURE" /p:ObjectNames="DeploymentUnitCategory:$(DEPLOYMENT_UNIT)"
/p:DEPLOY_TARGETS="$(BL_PATH)\DeploymentTargets\Azure\azure.targets"
/p:DeployFullPath="$(KB_PATH)\NetModel\Deploy\AZURE\$(DEPLOYMENT_UNIT)\$(DEPLOY_NAME)"
/p:WebSourcePath="$(KB_PATH)\NetModel\web" /p:GENERATOR="$(KBGENERATOR)"
name: DeploytoWebApp
- job: CloneOrPull
dependsOn: BuildAndDeploy
condition: succeeded()
steps:
- script: |
IF EXIST "$(GIT_BRANCH)" (
cd $(GIT_BRANCH)
git pull
) ELSE (
git clone https://$(GIT_USER):$(GIT_PASSWORD)@$(GIT_REPO) $(WORKING_DIR)\$(GIT_BRANCH)
)
workingDirectory: $(WORKING_DIR)
name: CloneOrPull
- job: PushSourcesToGit
dependsOn: CloneOrPull
condition: succeeded()
steps:
- script: >
xcopy /E /I /Y "$(KB_PATH)\NetModel" "$(WORKING_DIR)\$(GIT_BRANCH)"
cd $(GIT_BRANCH)
git add *
git commit -m "Commit build $(Build.BuildNumber)"
git push -u origin $(GIT_BRANCH)
workingDirectory: $(WORKING_DIR)
name: CommitPush