-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
159 lines (126 loc) · 6.27 KB
/
build.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
buildscript {
apply from: "https://raw.githubusercontent.com/blackducksoftware/integration-resources/master/gradle_common/buildscript-repositories.gradle", to: buildscript
apply from: 'https://raw.githubusercontent.com/blackducksoftware/integration-resources/master/gradle_common/buildscript-cgp-version.gradle'
ext {
javaTargetCompatibility = 8
javaSourceCompatibility = 8
}
ext['logback.version'] = '1.2.13'
dependencies { classpath "com.blackduck.integration:common-gradle-plugin:${managedCgpVersion}" }
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:6.7.0'
}
}
plugins {
id 'org.springframework.boot' version '2.6.6' apply false
}
project.ext.moduleName = 'com.blackduck.integration.hub-imageinspector-lib'
project.ext.javaUseAutoModuleName = 'true'
project.ext.junitShowStandardStreams = 'true'
version = '15.0.2-SNAPSHOT'
description = 'A library for creating Black Duck Input Output (BDIO) representing the packages installed in a Linux Docker image'
apply plugin: "io.spring.dependency-management"
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'com.blackduck.integration.library'
dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
mavenBom 'com.fasterxml.jackson:jackson-bom:2.12.4'
}
dependencies {
dependency 'ch.qos.logback:logback-core:1.2.13'
}
}
dependencies {
api 'com.blackduck.integration:integration-bdio:27.0.0'
api 'org.springframework:spring-context:5.3.34'
api 'org.apache.commons:commons-exec:1.3'
implementation 'com.github.luben:zstd-jni:1.5.0-4'
implementation 'ch.qos.logback:logback-classic:1.4.14'
testImplementation 'org.mockito:mockito-all:1.10.19'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2'
}
////////////////////////////////////////////////
// For integration tests: Build image tarfiles
task removeTestImage(type: Exec) {
ignoreExitValue true
commandLine "docker", "rmi", "blackducksoftware/centos_minus_vim_plus_bacula:1.0"
}
task removeTestBaseImage(type: Exec) {
ignoreExitValue true
commandLine "docker", "rmi", "centos:7.3.1611"
}
task createTestDockerfile(type: Dockerfile) {
destFile = project.file("${buildDir}/images/test/centos_minus_vim_plus_bacula/Dockerfile")
println "destFile: ${destFile}"
from 'centos:7.3.1611'
environmentVariable('LANG', 'en_US.UTF-8')
runCommand 'rpm -e vim-minimal && \
yum install -y bacula-director-5.2.13-23.1.el7 bacula-storage-5.2.13-23.1.el7 bacula-client-5.2.13-23.1.el7 \
bacula-console-5.2.13-23.1.el7'
}
task copyTestDockerFile(type: Exec) {
commandLine "cp", "src/test/resources/Dockerfile", "${buildDir}/images/test/Dockerfile"
}
task buildTestDockerImage(type: Exec, dependsOn: [removeTestBaseImage, removeTestImage, copyTestDockerFile]) {
commandLine "docker", "build", "--no-cache", "--tag", "blackducksoftware/centos_minus_vim_plus_bacula:1.0", \
"src/test/resources"
}
task buildTestDockerTarfile(type: Exec, dependsOn: buildTestDockerImage) {
outputs.files file("${buildDir}/images/test/centos_minus_vim_plus_bacula.tar")
commandLine "docker", "save", "-o", "${buildDir}/images/test/centos_minus_vim_plus_bacula.tar", \
"blackducksoftware/centos_minus_vim_plus_bacula:1.0"
}
task buildTestOciFilesystem(type: Exec, dependsOn: [buildTestDockerTarfile]) {
commandLine "echo", "Building of OCI test images is disabled for now"
//commandLine "skopeo", "copy", "docker-archive:${buildDir}/images/test/centos_minus_vim_plus_bacula.tar", "oci:${buildDir}/images/test/centos_minus_vim_plus_bacula-oci", \
//"--override-arch=amd64", "--override-os=linux"
}
task createTestFile(type: Exec) {
commandLine "touch", "${buildDir}/images/test/nopkgmgr/testfile.txt"
}
task createTestDockerfileNoPkgMgr(type: Dockerfile) {
destFile = project.file("${buildDir}/images/test/nopkgmgr/Dockerfile")
println "destFile: ${destFile}"
from 'scratch'
addFile('testfile.txt', '/')
}
task buildTestDockerImageNoPkgMgr(type: Exec, dependsOn: [createTestDockerfileNoPkgMgr, createTestFile]) {
commandLine "docker", "build", "--no-cache", "--tag", "blackducksoftware/nopkgmgr:1.0", \
"${buildDir}/images/test/nopkgmgr"
}
task buildTestDockerTarfileNoPkgMgr(type: Exec, dependsOn: buildTestDockerImageNoPkgMgr) {
outputs.files file("${buildDir}/images/test/nopkgmgr.tar")
commandLine "docker", "save", "-o", "${buildDir}/images/test/nopkgmgr.tar", \
"blackducksoftware/nopkgmgr:1.0"
}
task pullAlpineLatest(type: Exec) {
commandLine "docker", "pull", "alpine:latest"
}
task createImagesDir(type: Exec) {
commandLine "mkdir", "-p", "${buildDir}/images/test"
}
task buildAlpineTestDockerTarfile(type: Exec, dependsOn: [createImagesDir, pullAlpineLatest]) {
commandLine "docker", "save", "-o", "${buildDir}/images/test/alpine.tar", "alpine:latest"
}
task buildAlpineTestOciFilesystem(type: Exec, dependsOn: [buildAlpineTestDockerTarfile]) {
commandLine "echo", "Building of OCI test images is disabled for now"
// commandLine "skopeo", "copy", "docker-archive:${buildDir}/images/test/alpine.tar", "oci:${buildDir}/images/test/alpine-oci", \
// "--override-arch=amd64", "--override-os=linux"
}
task createAlpineDir(type: Exec) {
commandLine "mkdir", "-p", "build/images/test/alpine/tarExtraction/alpine.tar"
}
task buildTestTarfiles(dependsOn: [buildTestDockerTarfile, buildAlpineTestDockerTarfile, buildTestDockerTarfileNoPkgMgr]) {}
task buildTestOciFilesystems(dependsOn: [buildAlpineTestOciFilesystem, buildTestOciFilesystem]) {}
task unTarAlpine(type: Exec, dependsOn: [buildTestTarfiles, createAlpineDir]) {
workingDir "build/images/test/alpine/tarExtraction/alpine.tar"
commandLine "tar", "xvf", "../../../alpine.tar"
}
task prepareTestImagesAndFilesystems(dependsOn: [unTarAlpine, buildTestOciFilesystems]) {}
// Having trouble finding the best way to do this since the cgp change
// This builds the test images every time, but nothing else I've tried works across all builds
jar.dependsOn prepareTestImagesAndFilesystems
// End of stuff for integration tests
////////////////////////////////////////////////