@@ -87,34 +87,34 @@ public void run() {
8787 set -eu
8888 set -o pipefail
8989
90- echo "Using PROXY_URL : $PROXY_URL"
91-
9290 #fix this when we no longer need to run as root
9391 export HOME=${HOME:=/root}
92+ # Custom base working directory.
93+ export JBS_WORKDIR=${JBS_WORKDIR:=/var/workdir/workspace}
9494
9595 export LANG="en_US.UTF-8"
9696 export LC_ALL="en_US.UTF-8"
97- export JAVA_HOME=%s
98- export GRADLE_USER_HOME="/var/workdir/software/settings/.gradle"
97+ export JAVA_HOME=${JAVA_HOME:=%s}
9998 # This might get overridden by the tool home configuration below. This is
10099 # useful if Gradle/Ant also requires Maven configured.
101- export MAVEN_HOME=/opt/maven/3.8.8
100+ export MAVEN_HOME=${MAVEN_HOME:= /opt/maven/3.8.8}
102101 # If we run out of memory we want the JVM to die with error code 134
103102 export MAVEN_OPTS="-XX:+CrashOnOutOfMemoryError"
104103 # If we run out of memory we want the JVM to die with error code 134
105104 export JAVA_OPTS="-XX:+CrashOnOutOfMemoryError"
106- export %s_HOME=/opt/%s/%s
105+ export %s_HOME=${%s_HOME:=/opt/%s/%s}
106+ export GRADLE_USER_HOME="${JBS_WORKDIR}/software/settings/.gradle"
107107
108- mkdir -p /var/workdir/workspace/ logs /var/workdir/workspace /packages ${HOME}/.sbt/1.0 ${GRADLE_USER_HOME} ${HOME}/.m2
109- cd /var/workdir/workspace /source
108+ mkdir -p ${JBS_WORKDIR}/ logs ${JBS_WORKDIR} /packages ${HOME}/.sbt/1.0 ${GRADLE_USER_HOME} ${HOME}/.m2
109+ cd ${JBS_WORKDIR} /source
110110
111111 if [ ! -z ${JAVA_HOME+x} ]; then
112112 echo "JAVA_HOME:$JAVA_HOME"
113113 PATH="${JAVA_HOME}/bin:$PATH"
114114 fi
115115
116116 if [ ! -z ${MAVEN_HOME+x} ]; then
117- """ .formatted (javaHome , type .name (), type , buildToolVersion );
117+ """ .formatted (javaHome , type .name (), type . name (), type , buildToolVersion );
118118
119119 runBuild += getMavenSetup ();
120120
@@ -178,7 +178,7 @@ private String getContainerFile() {
178178 COPY .jbs/run-build.sh /var/workdir
179179 COPY . /var/workdir/workspace/source/
180180 RUN /var/workdir/run-build.sh
181- """ .formatted (recipeImage );;
181+ """ .formatted (recipeImage );
182182
183183 if (type == ToolType .ANT ) {
184184 // Don't think we need to mess with keystore as copy-artifacts is simply calling copy commands.
@@ -208,7 +208,7 @@ private String getContainerFile() {
208208 * altDeploymentDirectory to be used by default.
209209 */
210210 private String getMavenSetup () {
211- return """
211+ String result = """
212212 echo "MAVEN_HOME:$MAVEN_HOME"
213213 PATH="${MAVEN_HOME}/bin:$PATH"
214214
@@ -244,7 +244,7 @@ private String getMavenSetup() {
244244 <repositories>
245245 <repository>
246246 <id>artifacts</id>
247- <url>file:///var/workdir/workspace /artifacts</url>
247+ <url>file://${JBS_WORKDIR} /artifacts</url>
248248 <releases>
249249 <enabled>true</enabled>
250250 <checksumPolicy>ignore</checksumPolicy>
@@ -254,7 +254,7 @@ private String getMavenSetup() {
254254 <pluginRepositories>
255255 <pluginRepository>
256256 <id>artifacts</id>
257- <url>file:///var/workdir/workspace /artifacts</url>
257+ <url>file://${JBS_WORKDIR} /artifacts</url>
258258 <releases>
259259 <enabled>true</enabled>
260260 <checksumPolicy>ignore</checksumPolicy>
@@ -269,13 +269,45 @@ private String getMavenSetup() {
269269 </activation>
270270 <properties>
271271 <altDeploymentRepository>
272- local::file:///var/workdir/workspace /artifacts
272+ local::file://${JBS_WORKDIR} /artifacts
273273 </altDeploymentRepository>
274274 </properties>
275275 </profile>
276276 </profiles>
277277
278278 <interactiveMode>false</interactiveMode>
279+ """ ;
280+
281+ // This block is only needed when running outside of JBS
282+ if (isEmpty (System .getenv ("jvm-build-service" ))) {
283+ result += """
284+ <proxies>
285+ <proxy>
286+ <id>indy-http</id>
287+ <active>true</active>
288+ <protocol>http</protocol>
289+ <host>indy-generic-proxy</host>
290+ <port>80</port>
291+ <!-- <username>build-ADDTW3JAGHYAA+tracking</username> -->
292+ <username>${BUILD_ID}+tracking</username>
293+ <password>${MVN_TOKEN}</password>
294+ <nonProxyHosts>indy|localhost</nonProxyHosts>
295+ </proxy>
296+ <proxy>
297+ <id>indy-https</id>
298+ <active>true</active>
299+ <protocol>https</protocol>
300+ <host>indy-generic-proxy</host>
301+ <port>80</port>
302+ <username>${BUILD_ID}+tracking</username>
303+ <password>${MVN_TOKEN}</password>
304+ <nonProxyHosts>indy|localhost</nonProxyHosts>
305+ </proxy>
306+ </proxies>
307+ """ ;
308+ }
309+
310+ result += """
279311 </settings>
280312 EOF
281313
@@ -312,6 +344,8 @@ private String getMavenSetup() {
312344 </toolchains>
313345 EOF
314346 """ .formatted (javaVersion );
347+
348+ return result ;
315349 }
316350
317351
@@ -335,7 +369,7 @@ private String getGradleSetup() {
335369 systemProp.http.connectionTimeout=600000
336370
337371 # Settings for <https://github.com/vanniktech/gradle-maven-publish-plugin>
338- RELEASE_REPOSITORY_URL=file:///var/workdir/workspace /artifacts
372+ RELEASE_REPOSITORY_URL=file://${JBS_WORKDIR} /artifacts
339373 RELEASE_SIGNING_ENABLED=false
340374 mavenCentralUsername=
341375 mavenCentralPassword=
@@ -346,7 +380,7 @@ private String getGradleSetup() {
346380
347381 # Default deployment target
348382 # https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_system_properties
349- systemProp.maven.repo.local=/var/workdir/workspace /artifacts
383+ systemProp.maven.repo.local=${JBS_WORKDIR} /artifacts
350384 EOF
351385 """ ;
352386 }
@@ -405,7 +439,7 @@ private String getSbtSetup() {
405439 fi
406440 # TODO: we may need .allowInsecureProtocols here for minikube based tests that don't have access to SSL
407441 cat >"$HOME/.sbt/1.0/global.sbt" <<EOF
408- publishTo := Some(("MavenRepo" at s"file:/var/workdir/workspace /artifacts")),
442+ publishTo := Some(("MavenRepo" at s"file:${JBS_WORKDIR} /artifacts")),
409443 EOF
410444 """ ;
411445 }
0 commit comments