bug 1415391 - parameterize next_version and build_number. r=dustin
authorAki Sasaki <asasaki@mozilla.com>
Wed, 08 Nov 2017 15:52:48 -0800
changeset 444602 598578e14b9f833fbf3b27926fad0c1131b49304
parent 444601 0fd32f2a273f58413d3c1a9d53125208e9d1d201
child 444603 7d4154fe9a2644eee6302c6faf3a5d2c59b784a7
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1415391
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1415391 - parameterize next_version and build_number. r=dustin Instead of relying on environment variables, pass these in as parameters. MozReview-Commit-ID: An58Bu2kd1g
taskcluster/docs/parameters.rst
taskcluster/taskgraph/actions/release_promotion.py
taskcluster/taskgraph/decision.py
taskcluster/taskgraph/parameters.py
taskcluster/taskgraph/util/scriptworker.py
--- a/taskcluster/docs/parameters.rst
+++ b/taskcluster/docs/parameters.rst
@@ -133,16 +133,25 @@ Optimization
    Any tasks in the graph matching one of the labels will not be optimized out
    of the graph.
 
 ``existing_tasks``
    Specify tasks to optimize out of the graph. This is a dictionary of label to taskId.
    Any tasks in the graph matching one of the labels will use the previously-run
    taskId rather than submitting a new task.
 
+Release Promotion
+-----------------
+
+``build_number``
+   Specify the release promotion build number.
+
+``next_version``
+   Specify the next version for version bump tasks.
+
 Comm Push Information
 ---------------------
 
 These parameters correspond to the repository and revision of the comm-central
 repository to checkout. Their meaning is the same as the corresponding
 parameters for the gecko repository above. They are optional, but if any of
 them are specified, they must all be specified.
 
--- a/taskcluster/taskgraph/actions/release_promotion.py
+++ b/taskcluster/taskgraph/actions/release_promotion.py
@@ -1,18 +1,16 @@
 # -*- coding: utf-8 -*-
 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
-import os
-
 from .registry import register_callback_action
 
 from .util import (find_decision_task, find_existing_tasks_from_previous_kinds,
                    find_hg_revision_pushlog_id)
 from taskgraph.util.taskcluster import get_artifact
 from taskgraph.taskgraph import TaskGraph
 from taskgraph.decision import taskgraph_decision
 from taskgraph.parameters import Parameters
@@ -137,26 +135,24 @@ def is_release_promotion_available(param
                 'description': 'Next version.',
                 'default': '',
             },
         },
         "required": ['release_promotion_flavor', 'build_number'],
     }
 )
 def release_promotion_action(parameters, input, task_group_id, task_id, task):
-    os.environ['BUILD_NUMBER'] = str(input['build_number'])
     release_promotion_flavor = input['release_promotion_flavor']
     if release_promotion_flavor in VERSION_BUMP_FLAVORS:
         next_version = str(input.get('next_version', ''))
         if next_version == "":
             raise Exception(
                 "`next_version` property needs to be provided for %s "
                 "targets." % ', '.join(VERSION_BUMP_FLAVORS)
             )
-        os.environ['NEXT_VERSION'] = next_version
     promotion_config = RELEASE_PROMOTION_CONFIG[release_promotion_flavor]
 
     target_tasks_method = input.get(
         'target_tasks_method',
         promotion_config['target_tasks_method'].format(project=parameters['project'])
     )
     previous_graph_kinds = input.get(
         'previous_graph_kinds', promotion_config['previous_graph_kinds']
@@ -180,13 +176,15 @@ def release_promotion_action(parameters,
     parameters = get_artifact(previous_graph_ids[0], "public/parameters.yml")
     full_task_graph = get_artifact(previous_graph_ids[0], "public/full-task-graph.json")
     _, full_task_graph = TaskGraph.from_json(full_task_graph)
     parameters['existing_tasks'] = find_existing_tasks_from_previous_kinds(
         full_task_graph, previous_graph_ids, previous_graph_kinds
     )
     parameters['do_not_optimize'] = do_not_optimize
     parameters['target_tasks_method'] = target_tasks_method
+    parameters['build_number'] = str(input['build_number'])
+    parameters['next_version'] = next_version
 
     # make parameters read-only
     parameters = Parameters(**parameters)
 
     taskgraph_decision({}, parameters=parameters)
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -164,16 +164,18 @@ def get_decision_parameters(options):
     # Define default filter list, as most configurations shouldn't need
     # custom filters.
     parameters['filters'] = [
         'check_servo',
         'target_tasks_method',
     ]
     parameters['existing_tasks'] = {}
     parameters['do_not_optimize'] = []
+    parameters['build_number'] = 1
+    parameters['next_version'] = None
 
     # owner must be an email, but sometimes (e.g., for ffxbld) it is not, in which
     # case, fake it
     if '@' not in parameters['owner']:
         parameters['owner'] += '@noreply.mozilla.org'
 
     # use the pushdate as build_date if given, else use current time
     parameters['build_date'] = parameters['pushdate'] or int(time.time())
--- a/taskcluster/taskgraph/parameters.py
+++ b/taskcluster/taskgraph/parameters.py
@@ -26,26 +26,28 @@ def get_head_ref():
     return get_repository_object(GECKO).head_ref
 
 
 # Please keep this list sorted and in sync with taskcluster/docs/parameters.rst
 # Parameters are of the form: {name: default}
 PARAMETERS = {
     'base_repository': 'https://hg.mozilla.org/mozilla-unified',
     'build_date': lambda: int(time.time()),
+    'build_number': 1,
     'do_not_optimize': [],
     'existing_tasks': {},
     'filters': ['check_servo', 'target_tasks_method'],
     'head_ref': get_head_ref,
     'head_repository': 'https://hg.mozilla.org/mozilla-central',
     'head_rev': get_head_ref,
     'include_nightly': False,
     'level': '3',
     'message': '',
     'moz_build_date': lambda: datetime.now().strftime("%Y%m%d%H%M%S"),
+    'next_version': None,
     'optimize_target_tasks': True,
     'owner': 'nobody@mozilla.com',
     'project': 'mozilla-central',
     'pushdate': lambda: int(time.time()),
     'pushlog_id': '0',
     'release_history': {},
     'target_tasks_method': 'default',
     'try_mode': None,
--- a/taskcluster/taskgraph/util/scriptworker.py
+++ b/taskcluster/taskgraph/util/scriptworker.py
@@ -409,33 +409,24 @@ get_push_apk_rollout_percentage = functo
 def get_release_config(config, force=False):
     """Get the build number and version for a release task.
 
     Currently only applies to beetmover tasks.
 
     Args:
         config (dict): the task config that defines the target task method.
 
-    Raises:
-        ValueError: if a release graph doesn't define a valid
-            `os.environ['BUILD_NUMBER']`
-
     Returns:
         dict: containing both `build_number` and `version`.  This can be used to
             update `task.payload`.
     """
     release_config = {}
     if force or config.params['target_tasks_method'] in BEETMOVER_RELEASE_TARGET_TASKS:
-        next_version = str(os.environ.get("NEXT_VERSION", ""))
-        if next_version != "":
-            release_config['next_version'] = next_version
-        build_number = str(os.environ.get("BUILD_NUMBER", 1))
-        if not build_number.isdigit():
-            raise ValueError("Release graphs must specify `BUILD_NUMBER` in the environment!")
-        release_config['build_number'] = int(build_number)
+        release_config['next_version'] = str(config.params['next_version'])
+        release_config['build_number'] = int(config.params['build_number'])
         with open(VERSION_PATH, "r") as fh:
             version = fh.readline().rstrip()
         release_config['version'] = version
     return release_config
 
 
 def get_signing_cert_scope_per_platform(build_platform, is_nightly, config):
     if build_platform in (