Remove support for restricting job configurations, as it was unused.
Change-Id: Ifee8551e681756d59222c00ba71cf763848ca6b6
diff --git a/jenkins/build_defs/bazel-job-Gerrit.xml.tpl b/jenkins/build_defs/bazel-job-Gerrit.xml.tpl
index c008779..dbfb81b 100644
--- a/jenkins/build_defs/bazel-job-Gerrit.xml.tpl
+++ b/jenkins/build_defs/bazel-job-Gerrit.xml.tpl
@@ -63,8 +63,7 @@
{% if variables.SAUCE_ENABLED == "true" %}
sauce: "61b4846b-279d-4369-ae20-31e9d8b9bc66",
{% endif %}
- run_sequentially: {{ variables.RUN_SEQUENTIAL }},
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }}
+ run_sequentially: {{ variables.RUN_SEQUENTIAL }}
)
}
]]></script>
diff --git a/jenkins/build_defs/bazel-job-Global.xml.tpl b/jenkins/build_defs/bazel-job-Global.xml.tpl
index 6826b74..df2a4a1 100644
--- a/jenkins/build_defs/bazel-job-Global.xml.tpl
+++ b/jenkins/build_defs/bazel-job-Global.xml.tpl
@@ -63,8 +63,7 @@
{% if variables.SAUCE_ENABLED == "true" %}
sauce: "61b4846b-279d-4369-ae20-31e9d8b9bc66",
{% endif %}
- run_sequentially: {{ variables.RUN_SEQUENTIAL }},
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }}
+ run_sequentially: {{ variables.RUN_SEQUENTIAL }}
)
]]></script>
<sandbox>true</sandbox>
diff --git a/jenkins/build_defs/bazel-job-PR.xml.tpl b/jenkins/build_defs/bazel-job-PR.xml.tpl
index bf7eea5..f8beb34 100644
--- a/jenkins/build_defs/bazel-job-PR.xml.tpl
+++ b/jenkins/build_defs/bazel-job-PR.xml.tpl
@@ -69,8 +69,7 @@
{% if variables.SAUCE_ENABLED == "true" %}
sauce: "61b4846b-279d-4369-ae20-31e9d8b9bc66",
{% endif %}
- run_sequentially: {{ variables.RUN_SEQUENTIAL }},
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }}
+ run_sequentially: {{ variables.RUN_SEQUENTIAL }}
)
]]></script>
<sandbox>true</sandbox>
diff --git a/jenkins/build_defs/bazel-job.xml.tpl b/jenkins/build_defs/bazel-job.xml.tpl
index 8d7bf8b..527fdf0 100644
--- a/jenkins/build_defs/bazel-job.xml.tpl
+++ b/jenkins/build_defs/bazel-job.xml.tpl
@@ -50,8 +50,7 @@
{% if variables.SAUCE_ENABLED == "true" %}
sauce: "61b4846b-279d-4369-ae20-31e9d8b9bc66",
{% endif %}
- run_sequentially: {{ variables.RUN_SEQUENTIAL }},
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }}
+ run_sequentially: {{ variables.RUN_SEQUENTIAL }}
)
]]></script>
<sandbox>true</sandbox>
diff --git a/jenkins/build_defs/jenkins_job.bzl b/jenkins/build_defs/jenkins_job.bzl
index 5557e01..ab8be85 100644
--- a/jenkins/build_defs/jenkins_job.bzl
+++ b/jenkins/build_defs/jenkins_job.bzl
@@ -54,10 +54,6 @@
"production": "true",
} + MAIL_SUBSTITUTIONS
substitutions["SEND_EMAIL"] = "1"
- # RESTRICT_CONFIGURATION can be use to restrict configuration of the groovy jobs
- if (not "RESTRICT_CONFIGURATION" in substitutions) or (
- not substitutions["RESTRICT_CONFIGURATION"]):
- substitutions["RESTRICT_CONFIGURATION"] = "[:]"
expand_template(
name = name,
template = config,
diff --git a/jenkins/jobs/global/nightly.xml.tpl b/jenkins/jobs/global/nightly.xml.tpl
index 830cb73..255fd6a 100644
--- a/jenkins/jobs/global/nightly.xml.tpl
+++ b/jenkins/jobs/global/nightly.xml.tpl
@@ -43,8 +43,7 @@
branch: "master",
extra_bazelrc: params.EXTRA_BAZELRC,
refspec: "+refs/heads/*:refs/remotes/origin/*",
- configuration: '''{{ raw_imports['//jenkins/jobs:configs/bootstrap.json'].replace('\\', '\\\\').replace("'", "\\'") }}''',
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }})
+ configuration: '''{{ raw_imports['//jenkins/jobs:configs/bootstrap.json'].replace('\\', '\\\\').replace("'", "\\'") }}''')
</script>
<sandbox>true</sandbox>
</definition>
diff --git a/jenkins/jobs/global/presubmit.xml.tpl b/jenkins/jobs/global/presubmit.xml.tpl
index 3de580b..6e26601 100644
--- a/jenkins/jobs/global/presubmit.xml.tpl
+++ b/jenkins/jobs/global/presubmit.xml.tpl
@@ -62,8 +62,7 @@
branch: params.BRANCH,
extra_bazelrc: params.EXTRA_BAZELRC,
refspec: params.REFSPEC,
- configuration: '''{{ raw_imports['//jenkins/jobs:configs/bootstrap.json'].replace('\\', '\\\\').replace("'", "\\'") }}''',
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }})
+ configuration: '''{{ raw_imports['//jenkins/jobs:configs/bootstrap.json'].replace('\\', '\\\\').replace("'", "\\'") }}''')
delegate.reportUrl = "${currentBuild.getAbsoluteUrl()}Downstream_projects/"
}</script>
<sandbox>true</sandbox>
diff --git a/jenkins/jobs/global/release.xml.tpl b/jenkins/jobs/global/release.xml.tpl
index 7fd5e13..62b766f 100644
--- a/jenkins/jobs/global/release.xml.tpl
+++ b/jenkins/jobs/global/release.xml.tpl
@@ -41,8 +41,7 @@
branch: delegate.branch,
extra_bazelrc: params.EXTRA_BAZELRC,
refspec: "+refs/heads/*:refs/remotes/origin/* +refs/notes/*:refs/notes/*",
- configuration: '''{{ raw_imports['//jenkins/jobs:configs/bootstrap.json'].replace('\\', '\\\\').replace("'", "\\'") }}''',
- restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }})
+ configuration: '''{{ raw_imports['//jenkins/jobs:configs/bootstrap.json'].replace('\\', '\\\\').replace("'", "\\'") }}''')
}
</script>
<sandbox>true</sandbox>
diff --git a/jenkins/lib/src/build/bazel/ci/BazelConfiguration.groovy b/jenkins/lib/src/build/bazel/ci/BazelConfiguration.groovy
index 6aa27bc..72cb8a8 100644
--- a/jenkins/lib/src/build/bazel/ci/BazelConfiguration.groovy
+++ b/jenkins/lib/src/build/bazel/ci/BazelConfiguration.groovy
@@ -108,19 +108,7 @@
/**
* Flatten a list of configurations into a map of descriptor -> parameters.
*
- * Restrictions can be applied to configuration to select only configuration compatible with
- * the environment we run on (e.g. testing environment inside docker has only linux slave available).
- * The restrictions are specified by a map of descriptor key-values. A configuration will be selected
- * only if, for any key k in the descriptor, either the k is not a key of configurationRestrictions
- * or the value of the descriptor is in configurationRestrictions[k].
- *
- * Examples:
- * - configurationRestrictions = ["a": ["a", "b"], "b": []] would match descriptor
- * ["a": "a"], ["a": "b"], ["c": "whatever"] but not ["a": "c"] nor ["b": "whatever"]
- * - configurationRestrictions = ["node": ["linux-x86_64"]] would match only the descriptors that
- * point to an execution on a linux node.
- *
- * In addition, excludeConfigurations can be used to specifically deny certain configuration.
+ * excludeConfigurations can be used to specifically deny certain configuration.
* A configuration will be selected only if, for any key k in the descriptor, either the k
* is not a key of excludeConfigurations or the value of the descriptor is NOT in
* excludeConfigurations[k].
@@ -133,11 +121,10 @@
*/
public static Map<Map<String, String>, Map<String, Object>> flattenConfigurations(
List<BazelConfiguration> configurations,
- Map<String, List<String>> configurationRestrictions = [:],
Map<String, List<String>> excludeConfigurations = [:]) {
def result = [:]
for (conf in configurations) {
- result += conf.restrict(configurationRestrictions, excludeConfigurations).flatten()
+ result += conf.restrict(excludeConfigurations).flatten()
}
return result
}
@@ -169,22 +156,19 @@
return configurations
}
- private boolean matchRestriction(configurationRestrictions, excludeConfigurations) {
+ private boolean matchRestriction(excludeConfigurations) {
// Avoid closures because CPS is having trouble with it
for (def e : descriptor.entrySet()) {
- if ((e.key in configurationRestrictions) && !(e.value in configurationRestrictions[e.key])) {
- return true
- }
if ((e.key in excludeConfigurations) && (e.value in excludeConfigurations[e.key])) {
- return true
+ return true
}
}
return false
}
- private BazelConfiguration restrict(configurationRestrictions, excludeConfigurations) {
- if (!configurationRestrictions.isEmpty() || !excludeConfigurations.isEmpty()) {
- if (matchRestriction(configurationRestrictions, excludeConfigurations)) {
+ private BazelConfiguration restrict(excludeConfigurations) {
+ if (!excludeConfigurations.isEmpty()) {
+ if (matchRestriction(excludeConfigurations)) {
return EMPTY_CONFIGURATION
}
if (configurations.isEmpty()) {
@@ -192,7 +176,7 @@
} else {
def newConfigs = []
for (configuration in configurations) {
- def conf = configuration.restrict(configurationRestrictions, excludeConfigurations)
+ def conf = configuration.restrict(excludeConfigurations)
if (conf != EMPTY_CONFIGURATION) {
newConfigs << conf
}
diff --git a/jenkins/lib/tests/build/bazel/ci/BazelConfigurationTests.groovy b/jenkins/lib/tests/build/bazel/ci/BazelConfigurationTests.groovy
index 5cc7ade..a4c3863 100644
--- a/jenkins/lib/tests/build/bazel/ci/BazelConfigurationTests.groovy
+++ b/jenkins/lib/tests/build/bazel/ci/BazelConfigurationTests.groovy
@@ -127,30 +127,9 @@
}
@Test
- void testFlattenWithRestriction() {
- def result = BazelConfiguration.flattenConfigurations(
- BazelConfiguration.parse(JSON_TEST),
- [node: ["linux-x86_64", "windows-x86_64"]])
- def allKeys = result.collect {
- k, v -> k.collect { k1, v1 -> "${k1}=${v1}" }.toSorted().join(",") }.toSorted()
- assert allKeys.join("\n") == '''node=linux-x86_64
-node=windows-x86_64'''
- }
-
- @Test
- void testFlattenWithRestrictionNoWindows() {
- def result = BazelConfiguration.flattenConfigurations(
- BazelConfiguration.parse(JSON_TEST),
- [node: ["linux-x86_64"]])
- def allKeys = result.collect {
- k, v -> k.collect { k1, v1 -> "${k1}=${v1}" }.toSorted().join(",") }.toSorted()
- assert allKeys.join("\n") == '''node=linux-x86_64'''
- }
-
- @Test
void testFlattenWithExclusion() {
def result = BazelConfiguration.flattenConfigurations(
- BazelConfiguration.parse(JSON_TEST), [:],
+ BazelConfiguration.parse(JSON_TEST),
[node: ["ubuntu_16.04-x86_64", "darwin-x86_64"]])
def allKeys = result.collect {
k, v -> k.collect { k1, v1 -> "${k1}=${v1}" }.toSorted().join(",") }.toSorted()
diff --git a/jenkins/lib/vars/bazelCiConfiguredJob.groovy b/jenkins/lib/vars/bazelCiConfiguredJob.groovy
index c161505..d06f550 100644
--- a/jenkins/lib/vars/bazelCiConfiguredJob.groovy
+++ b/jenkins/lib/vars/bazelCiConfiguredJob.groovy
@@ -20,8 +20,7 @@
repository: config.repository,
branch: config.branch,
refspec: config.refspec,
- default_configuration: config.configuration,
- restrict_configuration: config.restrict_configuration
+ default_configuration: config.configuration
).entrySet().toArray()
for (int k = 0; k < entrySet.length; k++) {
def params = entrySet[k].value
@@ -61,8 +60,6 @@
* - bazel_version is the baseline for the version of Bazel, generally a parameter for the job.
* If set to 'custom', the job will try to fetch the Bazel binary from upstream.
* - configuration: JSON configuration, see BazelConfiguration
- * - restrict_configuration: A map of acceptable descriptor values. If provided, for each key,
- * only the values that are in that map will generate a configuration.
* - extra_bazelrc: extraneous content for the rc file, will go after all other options.
* Generally to be provided as a parameter of the job.
* - workspace: a directory, relative to the root of the repository, that contains
@@ -76,7 +73,6 @@
def call(config = [:]) {
config["bazel_version"] = config.get("bazel_version", "latest")
config["configuration"] = config.get("configuration", "[]")
- config["restrict_configuration"] = config.get("restrict_configuration", [:])
config["extra_bazelrc"] = config.get("extra_bazelrc", "")
config["workspace"] = config.get("workspace", "")
config["repository"] = config.get("repository", "")
diff --git a/jenkins/lib/vars/bootstrapBazelAll.groovy b/jenkins/lib/vars/bootstrapBazelAll.groovy
index bb16115..c975cee 100644
--- a/jenkins/lib/vars/bootstrapBazelAll.groovy
+++ b/jenkins/lib/vars/bootstrapBazelAll.groovy
@@ -16,7 +16,6 @@
def branch = config.get("branch", "master")
def refspec = config.get("refspec", "+refs/heads/*:refs/remotes/origin/*")
def configuration = config.get("configuration", "")
- def restrict_configuration = config.get("restrict_configuration", [:])
def jobs = [:]
// Convert to an array to avoid serialization issue with Jenkins
@@ -24,8 +23,7 @@
repository: config.repository,
branch: config.branch,
refspec: config.refspec,
- default_configuration: config.get("configuration", null),
- restrict_configuration: config.restrict_configuration
+ default_configuration: config.get("configuration", null)
).entrySet().toArray()
def values = []
def keys = []
diff --git a/jenkins/lib/vars/globalBazelTest.groovy b/jenkins/lib/vars/globalBazelTest.groovy
index 44137ce..357f370 100644
--- a/jenkins/lib/vars/globalBazelTest.groovy
+++ b/jenkins/lib/vars/globalBazelTest.groovy
@@ -22,7 +22,6 @@
def extra_bazelrc = config.get("extra_bazelrc", "")
def refspec = config.get("refspec", "+refs/heads/*:refs/remotes/origin/*")
def json_config = config.configuration
- def restrict_configuration = config.get("restrict_configuration", [])
stage("Startup global test") {
echo "Running global test for branch ${branch} (refspec: ${refspec})"
@@ -33,8 +32,7 @@
bootstrapBazelAll(repository: repository,
branch: branch,
refspec: refspec,
- configuration: json_config,
- restrict_configuration: restrict_configuration)
+ configuration: json_config)
}
@@ -54,7 +52,6 @@
if (!r_name.isEmpty()) {
pushRelease(name: r_name,
configuration: json_config,
- restrict_configuration: restrict_configuration,
excludes: ["**/*.bazel.build.tar*", "**/bazel", "**/bazel.exe"])
if (is_release) {
stage("Install new release on all nodes") {
diff --git a/jenkins/lib/vars/pushRelease.groovy b/jenkins/lib/vars/pushRelease.groovy
index b61e981..e6c0d8d 100644
--- a/jenkins/lib/vars/pushRelease.groovy
+++ b/jenkins/lib/vars/pushRelease.groovy
@@ -51,10 +51,10 @@
return JenkinsUtils.list(env, "${ws}/${dir}", excludes).collect { "${dir}/${it}" }
}
-private def listStashes(configuration, restrict_configuration) {
+private def listStashes(configuration) {
def result = []
def conf = BazelConfiguration.flattenConfigurations(
- BazelConfiguration.parse(configuration), restrict_configuration)
+ BazelConfiguration.parse(configuration))
for (k in conf.keySet()) {
if ("stash" in conf[k] || "archive" in conf[k]) {
result.add("bazel--node=${k.node}")
@@ -80,7 +80,7 @@
// unstash all the things
dir("artifacts") {
- def stashNames = listStashes(params.configuration, params.restrict_configuration)
+ def stashNames = listStashes(params.configuration)
for (def stashName : stashNames) {
unstash stashName
}
diff --git a/jenkins/lib/vars/readConfiguration.groovy b/jenkins/lib/vars/readConfiguration.groovy
index 791cdcb..c981830 100644
--- a/jenkins/lib/vars/readConfiguration.groovy
+++ b/jenkins/lib/vars/readConfiguration.groovy
@@ -20,8 +20,6 @@
// - files: the list of files to read from the repository (if the first one
// does not exists, try the second one and so on...), default to .ci/bazel.json.
// - default_configuration: default json content to use if the file cannot be found
-// - restrict_configuration: restriction to the returned configuration, see
-// BazelConfiguration.flattenConfiguration
def call(config = [:]) {
def conf = null
def files = config.get("files", [".ci/bazel.json"])
@@ -51,9 +49,8 @@
// We exclude the deploy slaves from being selected by the configuration, they
// have access to secrets.
return BazelConfiguration.flattenConfigurations(
- BazelConfiguration.parse(conf), config.get("restrict_configuration", [:]),
- ["node": ["deploy"]])
- } catch(Exception ex) {
+ BazelConfiguration.parse(conf), ["node": ["deploy"]])
+ } catch (Exception ex) {
error(filename != null ? "Failed to validate configuration (file was ${filename}): ${ex.message}"
: "Failed to validate default configuration: ${ex.message}")
}