forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elasticsearch.build-complete.gradle
58 lines (51 loc) · 2.16 KB
/
elasticsearch.build-complete.gradle
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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import java.nio.file.Files
String buildNumber = System.getenv('BUILD_NUMBER')
String performanceTest = System.getenv('BUILD_PERFORMANCE_TEST')
if (buildNumber && performanceTest == null) {
File uploadFile = file("build/${buildNumber}.tar.bz2")
project.gradle.buildFinished { result ->
println "build complete, generating: $uploadFile"
if (uploadFile.exists()) {
project.delete(uploadFile)
}
try {
ant.tar(destfile: uploadFile, compression: "bzip2", longfile: "gnu") {
fileset(dir: projectDir) {
Set<File> fileSet = fileTree(projectDir) {
include("**/*.hprof")
include("**/build/test-results/**/*.xml")
include("**/build/testclusters/**")
exclude("**/build/testclusters/**/data/**")
exclude("**/build/testclusters/**/distro/**")
exclude("**/build/testclusters/**/repo/**")
exclude("**/build/testclusters/**/extract/**")
}
.files
.findAll { Files.isRegularFile(it.toPath()) }
if (fileSet.empty) {
// In cases where we don't match any workspace files, exclude everything
ant.exclude(name: "**/*")
} else {
fileSet.each {
ant.include(name: projectDir.toPath().relativize(it.toPath()))
}
}
}
fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
}
fileset(dir: "${gradle.gradleUserHomeDir}/workers", followsymlinks: false)
fileset(dir: "${project.projectDir}/.gradle/reaper", followsymlinks: false, erroronmissingdir: false)
}
} catch (Exception e) {
logger.lifecycle("Failed to archive additional logs", e)
}
}
}