1
+ # ##########################################################
2
+ # Script for creating mda-file (Mendix Deployment Archive)
3
+ # ##########################################################
4
+ #
5
+ # Prerequisites: Set-ExecutionPolicy RemoteSigned
6
+ #
7
+ # ##########################################################
8
+
9
+ Param (
10
+ [Parameter (Position = 0 )]
11
+ [String ]$apiheaders ,
12
+ [String ]$environmentconfig
13
+ )
14
+
15
+ # Check if the functions script is in place.
16
+ $scriptDirectory = Split-Path - Path $MyInvocation.MyCommand.Definition - Parent
17
+ try {
18
+ . (" $ScriptDirectory \mendix_ci_functions.ps1" )
19
+ }
20
+ catch {
21
+ Write-Host " Error while loading required supporting PowerShell Scripts."
22
+ }
23
+
24
+ # FIRST CHECK INPUT OF REQUIRED VARIABLE
25
+ if (! $apiheaders ) {
26
+ Write-Host " API headers are required."
27
+ exit
28
+ }
29
+
30
+ if (! $envconfig ) {
31
+ Write-Host " Environment configuration is required."
32
+ exit
33
+ }
34
+
35
+ # INCLUDE FUNCTIONS FILE
36
+ Include ' .\mendix_ci_functions.ps1'
37
+
38
+ # STATIC VARIABLE ENDPOINT
39
+ $url = ' https://deploy.mendix.com/api/1/'
40
+
41
+ # IMPORT MENDIX API CREDENTIALS
42
+ $headers = Import-PowerShellDataFile $apiheaders
43
+
44
+ # IMPORT ENVIRONMENT CONFIGURATION
45
+ $configuration = Import-PowerShellDataFile $environmentconfig
46
+
47
+ # Get and set the specific environment config
48
+ $appName = $configuration.Environment.AppName
49
+ $branchName = $configuration.Environment.BranchName
50
+
51
+ $branch = Get-Branch $headers $url $appName $branchName
52
+
53
+ " Branch to build: $branch "
54
+ $latestBuiltRevision = $branch.LatestTaggedVersion.Substring ($branch.LatestTaggedVersion.LastIndexOf (' .' ) + 1 )
55
+ $latestRevisionNumber = $branch.LatestRevisionNumber
56
+
57
+ if ($latestBuiltRevision -eq $latestRevisionNumber ) {
58
+ " It is not needed to build, as the latest revision is already built."
59
+ exit
60
+ }
61
+
62
+ $versionWithoutRevision = $branch.LatestTaggedVersion.Remove ($branch.LatestTaggedVersion.LastIndexOf (' .' ))
63
+ $packageId = Start-Build $headers $url $appName $branchName $latestRevisionNumber $versionWithoutRevision
64
+ $built = Wait-For - Built $headers $url $appName $packageId 600
65
+
66
+ if ($built -eq $false ) {
67
+ " No build succeeded within 10 minutes."
68
+ exit
69
+ }
0 commit comments