How to use the taskcluster.fromNow function in taskcluster

To help you get started, we’ve selected a few taskcluster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-mobile / firefox-tv / tools / taskcluster / tasks.py View on Github external
def _craft_base_task(self, name, extend_task):
        return {
            'taskGroupId': self.task_group_id,
            'schedulerId': 'taskcluster-github',
            'created': taskcluster.stringDate(datetime.datetime.now()),
            'deadline': taskcluster.stringDate(taskcluster.fromNow('1 day')),
            'metadata': {
                'name': name,
                'description': '',
                'owner': self.owner,
                'source': f'{self.repo_url}/raw/{self.commit}/.taskcluster.yml',
            },
            **extend_task
        }
github mozilla / glean / automation / taskcluster / decisionlib.py View on Github external
def from_now_json(self, offset):
        """
        Same as `taskcluster.fromNowJSON`, but uses the creation time of `self` for “now”.
        """
        return taskcluster.stringDate(taskcluster.fromNow(offset, dateObj=self.now))
github mozilla / normandy / ci / taskcluster / bin / decision.py View on Github external
path = spec['path']
                env[spec['env_var']] = f'{BASE_URL}/task/{task_id}/artifacts/{path}'

            task_id = idMaker(task['name'])
            res = session.put(f'{BASE_URL}/task/{task_id}', data=dumpJson({
                'metadata': {
                    'name': task['name'],
                    'description': task['description'],
                    'owner': owner,
                    'source': source,
                },
                'provisionerId': 'aws-provisioner-v1',
                'workerType': 'gecko-1-b-linux',
                'schedulerId': 'taskcluster-github',
                'taskGroupId': decisionTaskId,
                'created': fromNow('0 seconds'),
                'deadline': fromNow('1 day'),
                'expires': fromNow('365 days'),
                'payload': {
                    'image': 'mozilla/normandy-taskcluster:2018-01-18',
                    'command': [
                        '/bin/bash',
                        '-c',
                        ' && '.join([
                            'apt-get update',
                            'apt-get install -y git',
                            'mkdir /artifacts',
                            'cd ~',
                            'git clone $GITHUB_HEAD_REPO_URL normandy',
                            'pushd normandy',
                            'git checkout $GITHUB_HEAD_SHA',
                            'popd',
github mozilla / mozilla_ci_tools / mozci / taskcluster / tc.py View on Github external
def refresh_timestamps(task):
    ''' It refreshes the timestamps of the task. '''
    # XXX split this function
    LOG.debug("Updating timestamps of task.")

    LOG.debug("Original task: (Limit 1024 char)")
    LOG.debug(str(json.dumps(task))[:1024])

    artifacts = task['payload'].get('artifacts', {})
    for artifact, definition in artifacts.iteritems():
        definition['expires'] = taskcluster_client.fromNow('%s days' % 365)

    # https://bugzilla.mozilla.org/show_bug.cgi?id=1190660
    # TC workers create public logs which are 365 days; if the task expiration
    # date is the same or less than that we won't have logs for the task
    task['expires'] = taskcluster_client.fromNow('%s days' % (365 + 1))
    now = datetime.datetime.utcnow()
    tomorrow = now + datetime.timedelta(hours=24)
    task['created'] = taskcluster_client.stringDate(now)
    task['deadline'] = taskcluster_client.stringDate(tomorrow)

    LOG.debug("Contents of new task: (Limit 1024 char)")
    LOG.debug(str(task)[:1024])

    return task
github mozilla-mobile / fenix / automation / taskcluster / decision_task_nightly.py View on Github external
def generate_build_task(apks, is_staging):
    artifacts = {'public/{}'.format(os.path.basename(apk)): {
        "type": 'file',
        "path": apk,
        "expires": taskcluster.stringDate(taskcluster.fromNow('1 year')),
    } for apk in apks}

    checkout = (
        "export TERM=dumb && git fetch {} {} --tags && "
        "git config advice.detachedHead false && "
        "git checkout {}".format(
            GITHUB_HTTP_REPOSITORY, HEAD_BRANCH, HEAD_REV
        )
    )
    sentry_secret = '{}project/mobile/fenix/sentry'.format('garbage/staging/' if is_staging else '')
    leanplum_secret = '{}project/mobile/fenix/leanplum'.format('garbage/staging/' if is_staging else '')

    return taskcluster.slugId(), BUILDER.build_task(
        name="(Fenix) Build task",
        description="Build Fenix from source code.",
        command=(
github mozilla / mozilla_ci_tools / mozci / sources / tc.py View on Github external
LOG.debug("Original task: (Limit 1024 char)")
        LOG.debug(str(json.dumps(task))[:1024])
        new_task_id = taskcluster_client.slugId()

        artifacts = task['payload'].get('artifacts', {})
        for artifact, definition in artifacts.iteritems():
            definition['expires'] = taskcluster_client.fromNow('%s days' % one_year)

        # The task group will be identified by the ID of the only
        # task in the group
        task['taskGroupId'] = new_task_id
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1190660
        # TC workers create public logs which are 365 days; if the task expiration
        # date is the same or less than that we won't have logs for the task
        task['expires'] = taskcluster_client.fromNow('%s days' % (one_year + 1))
        now = datetime.datetime.utcnow()
        tomorrow = now + datetime.timedelta(hours=24)
        task['created'] = taskcluster_client.stringDate(now)
        task['deadline'] = taskcluster_client.stringDate(tomorrow)

        LOG.debug("Contents of new task: (Limit 1024 char)")
        LOG.debug(str(task)[:1024])

        if not dry_run:
            LOG.info("Attempting to schedule new task with task_id: {}".format(new_task_id))
            result = queue.createTask(new_task_id, task)
            LOG.debug(json.dumps(result))
            LOG.info("{}/task-inspector/#{}".format(TASKCLUSTER_TOOLS_HOST, new_task_id))
        else:
            LOG.info("Dry-run mode: Nothing was retriggered.")
github mozilla / application-services / automation / taskcluster / decisionlib.py View on Github external
def from_now_json(self, offset):
        """
        Same as `taskcluster.fromNowJSON`, but uses the creation time of `self` for “now”.
        """
        return taskcluster.stringDate(taskcluster.fromNow(offset, dateObj=self.now))
github mozilla / normandy / ci / taskcluster / bin / decision.py View on Github external
env[spec['env_var']] = f'{BASE_URL}/task/{task_id}/artifacts/{path}'

            task_id = idMaker(task['name'])
            res = session.put(f'{BASE_URL}/task/{task_id}', data=dumpJson({
                'metadata': {
                    'name': task['name'],
                    'description': task['description'],
                    'owner': owner,
                    'source': source,
                },
                'provisionerId': 'aws-provisioner-v1',
                'workerType': 'gecko-1-b-linux',
                'schedulerId': 'taskcluster-github',
                'taskGroupId': decisionTaskId,
                'created': fromNow('0 seconds'),
                'deadline': fromNow('1 day'),
                'expires': fromNow('365 days'),
                'payload': {
                    'image': 'mozilla/normandy-taskcluster:2018-01-18',
                    'command': [
                        '/bin/bash',
                        '-c',
                        ' && '.join([
                            'apt-get update',
                            'apt-get install -y git',
                            'mkdir /artifacts',
                            'cd ~',
                            'git clone $GITHUB_HEAD_REPO_URL normandy',
                            'pushd normandy',
                            'git checkout $GITHUB_HEAD_SHA',
                            'popd',
                            task['command'],