-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowserstack.gradle
More file actions
30 lines (29 loc) · 1.2 KB
/
browserstack.gradle
File metadata and controls
30 lines (29 loc) · 1.2 KB
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
import groovy.json.JsonSlurper
/**
* This task will delete all previously uploaded AppLive apps for the provided customId
*/
ext.deleteAppLiveWithCustomId = { customId ->
def response = new ByteArrayOutputStream()
exec {
executable "curl";
args "-u", "$rootProject.browserStackUser:$rootProject.browserStackKey", "-X",
"GET", "https://api-cloud.browserstack.com/app-live/recent_apps/${customId}"
standardOutput = response;
}
def json = new JsonSlurper().parseText(response.toString())
if (!(json instanceof List<Map>)) {
logger.lifecycle("[BROWSERSTACK] No apps to delete for customId[${customId}] response[${json}]")
return
}
for (def app : (List<Map>) json) {
if (!(app.containsKey("app_id"))) {
continue
}
def appId = URLEncoder.encode("${app.app_id}", "UTF-8")
logger.lifecycle("[BROWSERSTACK] Deleting app with customId[${customId}] and appId[${appId}]")
exec {
executable "curl"; args "-u", "$rootProject.browserStackUser:$rootProject.browserStackKey", "-X",
"DELETE", "https://api-cloud.browserstack.com/app-live/app/delete/${appId}"
}
}
}