File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed
buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/ci Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2018 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ package com.google.firebase.gradle.plugins.ci
16
+
17
+ import java.util.regex.Matcher
18
+ import java.util.regex.Pattern
19
+
20
+ class Environment {
21
+ private static final Pattern ENV_PATTERN = Pattern . compile(/ \$\( ([A-Za-z0-9_-]+)\) / )
22
+
23
+ static String expand (String value ) {
24
+ Matcher m = ENV_PATTERN . matcher(value)
25
+ while (m. find()) {
26
+ value = value. replace(m. group(), env(m. group(1 )))
27
+ }
28
+ return value
29
+
30
+ }
31
+
32
+ private static String env (String varName ) {
33
+ return Optional . ofNullable(System . getenv(varName)). orElse(' ' )
34
+ }
35
+ }
Original file line number Diff line number Diff line change 15
15
package com.google.firebase.gradle.plugins.ci.device
16
16
17
17
import com.android.builder.testing.api.TestServer
18
+ import com.google.firebase.gradle.plugins.ci.Environment
19
+
18
20
import java.nio.file.Paths
19
21
import org.gradle.api.Project
20
22
21
23
22
24
class FirebaseTestServer extends TestServer {
23
- private static final String BUCKET_NAME = ' android-ci'
25
+ private static final String DEFAULT_BUCKET_NAME = ' android-ci'
24
26
final Project project
25
27
final FirebaseTestLabExtension extension
26
28
final Random random
@@ -62,10 +64,10 @@ class FirebaseTestServer extends TestServer {
62
64
}
63
65
64
66
private List<String > getResultUploadArgs () {
65
- Optional<String > resultsBucket = Optional . ofNullable(System . getenv(' FTL_RESULTS_BUCKET' ))
66
- Optional<String > resultsDir = Optional . ofNullable(System . getenv(' FTL_RESULTS_DIR' ))
67
+ Optional<String > resultsBucket = Optional . ofNullable(System . getenv(' FTL_RESULTS_BUCKET' )). map( Environment . &expand)
68
+ Optional<String > resultsDir = Optional . ofNullable(System . getenv(' FTL_RESULTS_DIR' )). map( Environment . &expand)
67
69
68
- List<String > args = [' --results-bucket' , resultsBucket. orElse(' android-ci ' )]
70
+ List<String > args = [' --results-bucket' , resultsBucket. orElse(DEFAULT_BUCKET_NAME )]
69
71
if (resultsDir. isPresent()) {
70
72
args + = [' --results-dir' , Paths . get(resultsDir. get(), " ${ project.path} _${ random.nextLong()} " )]
71
73
}
You can’t perform that action at this time.
0 commit comments