How to use the cumulusci.core.tasks.BaseTask function in cumulusci

To help you get started, we’ve selected a few cumulusci 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 SFDO-Tooling / CumulusCI / cumulusci / tasks / metadata / managed_src.py View on Github external
findReplace(
            self.managed_token,
            "",
            os.path.join(self.options["path"], "triggers"),
            "*.trigger",
            self.logger,
        )

        self.logger.info(
            "{} has been stripped from all classes and triggers in {}".format(
                self.managed_token, self.options["path"]
            )
        )


class RevertManagedSrc(BaseTask):
    task_options = {
        "path": {
            "description": "The path containing metadata to process for managed deployment",
            "required": True,
        },
        "revert_path": {
            "description": "The path to copy the original metadata to for the revert call",
            "required": True,
        },
    }

    def _run_task(self):
        # Check that revert_path does exists
        if not os.path.isdir(self.options["revert_path"]):
            raise TaskOptionsError(
                "The revert_path {} does not exist or is not a directory".format(
github SFDO-Tooling / CumulusCI / cumulusci / tasks / command.py View on Github external
SalesforceCommand - run a command with credentials passed
SalesforceBrowserTest - a task designed to wrap browser testing that could run locally or remotely
"""

import json
import os
import subprocess
import sys

from cumulusci.core.exceptions import CommandException
from cumulusci.core.exceptions import BrowserTestFailure
from cumulusci.core.tasks import BaseTask
from cumulusci.core.utils import process_bool_arg


class Command(BaseTask):
    """ Execute a shell command in a subprocess """

    task_docs = """
        **Example Command-line Usage::** cci task run command -o command "echo 'Hello command task!'"

        **Example Task to Run Command::**
        hello_world:
            description: Says hello world
            class_path: cumulusci.tasks.command.Command
            options:
            command: echo 'Hello World!'
    """

    task_options = {
        "command": {"description": "The command to execute", "required": True},
        "dir": {
github SFDO-Tooling / CumulusCI / cumulusci / tasks / util.py View on Github external
"level": {"description": "The logger level to use", "required": True},
        "line": {"description": "A formatstring like line to log", "required": True},
        "format_vars": {"description": "A Dict of format vars", "required": False},
    }

    def _init_options(self, kwargs):
        super(LogLine, self)._init_options(kwargs)
        if "format_vars" not in self.options:
            self.options["format_vars"] = {}

    def _run_task(self):
        log = getattr(self.logger, self.options["level"])
        log(self.options["line"].format(**self.options["format_vars"]))


class PassOptionAsResult(BaseTask):
    task_options = {
        "result": {"description": "The result for the task", "required": True}
    }

    def _run_task(self):
        return self.options["result"]


class PassOptionAsReturnValue(BaseTask):
    task_options = {
        "key": {"required": True, "description": "The return value key to use."},
        "value": {"required": True, "description": "The value to set."},
    }

    def _run_task(self):
        self.return_values[self.options["key"]] = self.options["value"]
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / BaseSalesforceTask.py View on Github external
from cumulusci.core.tasks import BaseTask
from cumulusci.core.exceptions import ServiceNotValid, ServiceNotConfigured
from cumulusci import __version__


class BaseSalesforceTask(BaseTask):
    name = "BaseSalesforceTask"
    salesforce_task = True

    def _get_client_name(self):
        try:
            app = self.project_config.keychain.get_service("connectedapp")
            return app.client_id
        except (ServiceNotValid, ServiceNotConfigured):
            return "CumulusCI/{}".format(__version__)

    def _run_task(self):
        raise NotImplementedError("Subclasses should provide their own implementation")

    def _update_credentials(self):
        orig_config = self.org_config.config.copy()
        self.org_config.refresh_oauth_token(self.project_config.keychain)
github SFDO-Tooling / CumulusCI / cumulusci / tasks / push / tasks.py View on Github external
class GetSubscriberList(BaseSalesforceApiTask):
    """ Get subscribed org info and write to local CSV file """

    task_options = {
        "filename": {
            "description": "File where org IDs will be written",
            "required": True,
        }
    }

    def _run_task(self):
        raise NotImplementedError


class FilterSubscriberList(BaseTask):
    """
    Filter subscriber org list by org type, version.
    Write file with org IDs only
    """

    task_options = {
        "file_in": {"description": "CSV file with full org info", "required": True},
        "file_out": {
            "description": "File where org IDs will be written",
            "required": True,
        },
        "org_type": {"description": "Filter by org type"},
        "version": {"description": "Filter by installed package version"},
    }

    def _run_task(self):
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforcedx.py View on Github external
import sarge

from cumulusci.core.exceptions import SalesforceDXException
from cumulusci.core.tasks import BaseTask

class BaseSalesforceDXTask(BaseTask):
    task_options = {
        'command': {
            'description': 'The Saleforce DX command to call.  For example: force:src:push',
            'required': True,
        },
        'options': {
            'description': 'The command line options to pass to the command',
        },
    }

    def _call_salesforce_dx(self, command, options=None):
        full_command = 'heroku ' + command
        if options:
            full_command += ' {}'.format(options)

        full_command += ' -u {}'.format(self.org_config.username)
github SFDO-Tooling / CumulusCI / cumulusci / tasks / metadata / package.py View on Github external
# Skip non-directories
        if not os.path.isdir(path):
            return members

        # item is a directory; add directory to members and ignore processing directory's files
        members.append(item)

        return members


class DocumentParser(MetadataFolderParser):
    def _parse_subitem(self, item, subitem):
        return [item + "/" + subitem]


class UpdatePackageXml(BaseTask):
    task_options = {
        "path": {
            "description": "The path to a folder of metadata to build the package.xml from",
            "required": True,
        },
        "output": {"description": "The output file, defaults to 
github SFDO-Tooling / CumulusCI / cumulusci / tasks / mrbelvedere.py View on Github external
import http.client
import json

import requests

from cumulusci.core.exceptions import MrbelvedereError
from cumulusci.core.tasks import BaseTask


class BaseMrbelvedereTask(BaseTask):
    def _init_task(self):
        self.mrbelvedere_config = self.project_config.keychain.get_service(
            "mrbelvedere"
        )


class MrbelvederePublish(BaseMrbelvedereTask):

    task_options = {
        "tag": {"description": "The tag to publish to mrbelvedere", "required": True}
    }

    def _init_task(self):
        super(MrbelvederePublish, self)._init_task()
        self.dependencies_url = "{}/{}/dependencies".format(
            self.mrbelvedere_config.base_url,
github SFDO-Tooling / CumulusCI / cumulusci / tasks / ant.py View on Github external
import base64
import logging
import os
import sarge
import tempfile
import zipfile

from cumulusci.core.exceptions import AntTargetException
from cumulusci.core.exceptions import ApexTestException
from cumulusci.core.exceptions import DeploymentException
from cumulusci.core.tasks import BaseTask
from cumulusci.tasks.salesforce import BaseSalesforceTask
from cumulusci.utils import CUMULUSCI_PATH

class AntTask(BaseTask):
    name = 'AntTask'

    task_options = {
        'target': {
            'description': 'The ant target to run',
            'required': True,
        },
        'verbose': {
            'description': 'The ant target to run',
            'required': False,
        }
    }

    def _run_task(self):
        target = self.task_config.options__target
        env = self._get_ant_env()
github SFDO-Tooling / CumulusCI / cumulusci / tasks / github / base.py View on Github external
from cumulusci.core.github import get_github_api_for_repo
from cumulusci.core.tasks import BaseTask


class BaseGithubTask(BaseTask):
    def _init_task(self):
        self.github_config = self.project_config.keychain.get_service("github")
        self.github = get_github_api_for_repo(
            self.project_config.keychain,
            self.project_config.repo_owner,
            self.project_config.repo_name,
        )

    def get_repo(self):
        return self.github.repository(
            self.project_config.repo_owner, self.project_config.repo_name
        )