-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
build-test-azure.xml
114 lines (86 loc) · 3.46 KB
/
build-test-azure.xml
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
<?xml version="1.0"?>
<project basedir="." name="portal-test-azure" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="delete-azure-containers">
<sequential>
<local name="container.list" />
<exec executable="az" outputproperty="container.list">
<arg line="storage container list --account-name isit35689storage --prefix lfr-qa-poshi-test --connection-string ${azure.connection.string}" />
</exec>
<script language="javascript"><![CDATA[
var containerList = project.getProperty("container.list");
var expiredContainers = [];
var json = JSON.parse(containerList);
for (var i = 0; i < json.length; i++) {
var container = json[i];
var name = JSON.stringify(container.name);
if (name.indexOf('lfr-qa-poshi-test') > -1) {
var lastModified = container.properties.lastModified;
var currentDate = new Date();
var containerDate = new Date(lastModified);
var diffHours = (currentDate - containerDate) / (1000 * 60 * 60);
if (diffHours > 12) {
expiredContainers.push(name);
}
}
}
project.setProperty("expired.containers", expiredContainers.toString());]]>
</script>
<for list="${expired.containers}" param="delete.name">
<sequential>
<echo>Expired Container: @{delete.name}</echo>
<exec executable="az">
<arg line="storage container delete --account-name isit35689storage --name @{delete.name} --connection-string ${azure.connection.string}" />
</exec>
</sequential>
</for>
</sequential>
</macrodef>
<target name="assert-document-in-container">
<local name="container.blobs" />
<exec executable="az" outputproperty="container.blobs">
<arg line="storage blob list --container-name lfr-qa-poshi-test-${azure.container.id} --account-name isit35689storage --prefix ${companyId}/${groupId} --output table --connection-string ${azure.connection.string}" />
</exec>
<echo>${container.blobs}</echo>
<if>
<contains string="${container.blobs}" substring="1.0" />
<then>
<echo>Document is in container.</echo>
</then>
<else>
<fail>Document is not in container.</fail>
</else>
</if>
</target>
<target name="assert-no-document-in-container">
<local name="container.blobs" />
<exec executable="az" outputproperty="container.blobs">
<arg line="storage blob list --container-name lfr-qa-poshi-test-${azure.container.id} --account-name isit35689storage --prefix ${companyId}/${groupId} --output table --connection-string ${azure.connection.string}" />
</exec>
<echo>${container.blobs}</echo>
<if>
<not>
<isset property="${container.blobs}" />
</not>
<then>
<echo>The container is empty.</echo>
</then>
<else>
<fail>The container is not empty.</fail>
</else>
</if>
</target>
<target name="create-azure-container">
<local name="container.create.output" />
<exec executable="az" outputproperty="container.create.output">
<arg line="storage container create -n lfr-qa-poshi-test-${azure.container.id} --public-access container --account-name isit35689storage --connection-string ${azure.connection.string}" />
</exec>
<echo>${container.create.output}</echo>
</target>
<target name="delete-azure-container">
<exec executable="az">
<arg line="storage container delete --account-name isit35689storage --name lfr-qa-poshi-test-${azure.container.id} --connection-string ${azure.connection.string}" />
</exec>
<delete-azure-containers />
</target>
</project>