How to use the cumulusci.tasks.salesforce.Deploy 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 / salesforce.py View on Github external
super(DeployNamespaced, self)._run_task()
    

class DeployNamespacedBundles(DeployBundles):
    """ DEPRECATED: This is no longer necessary now that namespace_* options exist on DeployBundles itself """
    name = 'DeployNamespacedBundles'

    def _run_task(self):
        self.logger.warning('DEPRECATED: The DeployNamespacedBundles task class is deprecated.  Please switch to using the DeployBundles task and the namespace_inject option to accomplish the same functionality.  This class will be removed in a future release')
        super(DeployNamespacedBundles, self)._run_task()

uninstall_task_options = Deploy.task_options.copy()
uninstall_task_options['purge_on_delete'] = {
    'description': 'Sets the purgeOnDelete option for the deployment. Defaults to True',
}
class BaseUninstallMetadata(Deploy):
    task_options = uninstall_task_options

    def _init_options(self, kwargs):
        super(BaseUninstallMetadata, self)._init_options(kwargs)
        self.options['purge_on_delete'] = process_bool_arg(self.options.get(
            'purge_on_delete',
            True,
        ))

    def _get_api(self, path=None):
        destructive_changes = self._get_destructive_changes(path=path)
        if not destructive_changes:
            return
        package_zip = DestructiveChangesZipBuilder(
            destructive_changes,
            self.project_config.project__package__api_version,
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce.py View on Github external
generator = PackageXmlGenerator(
            directory = path,
            api_version = self.project_config.project__package__api_version,
            delete = True,
        )
        namespace = ''
        if self.options['managed'] in [True, 'True', 'true']:
            if self.options['namespace']:
                namespace = self.options['namespace'] + '__'

        destructive_changes = generator()
        destructive_changes = destructive_changes.replace(self.options['filename_token'], namespace)

        return destructive_changes

class UpdateAdminProfile(Deploy):
    name = 'UpdateAdminProfile'

    task_options = {
        'package_xml': {
            'description': 'Override the default package.xml file for retrieving the Admin.profile and all objects and classes that need to be included by providing a path to your custom package.xml',
        }
    }

    def _init_options(self, kwargs):
        super(UpdateAdminProfile, self)._init_options(kwargs)

        if 'package_xml' not in self.options:
            self.options['package_xml'] = os.path.join(CUMULUSCI_PATH, 'cumulusci', 'files', 'admin_profile.xml')

        self.options['package_xml_path'] = self.options['package_xml']
        with open(self.options['package_xml_path'], 'r') as f:
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / UpdateAdminProfile.py View on Github external
import os
import shutil
import tempfile

from cumulusci.salesforce_api.metadata import ApiRetrieveUnpackaged
from cumulusci.core.exceptions import TaskOptionsError
from cumulusci.core.utils import process_bool_arg
from cumulusci.tasks.salesforce import Deploy
from cumulusci.utils import CUMULUSCI_PATH
from cumulusci.utils import elementtree_parse_file


class UpdateAdminProfile(Deploy):
    name = "UpdateAdminProfile"

    task_options = {
        "package_xml": {
            "description": "Override the default package.xml file for retrieving the Admin.profile and all objects and classes that need to be included by providing a path to your custom package.xml"
        },
        "record_types": {
            "description": "A list of dictionaries containing the required key `record_type` with a value specifying the record type in format ..  Record type names can use the token strings {managed} and {namespaced_org} for namespace prefix injection as needed.  By default, all listed record types will be set to visible and not default.  Use the additional keys `visible`, `default`, and `person_account_default` set to true/false to override.  NOTE: Setting record_types is only supported in cumulusci.yml, command line override is not supported."
        },
        "managed": {
            "description": "If True, uses the namespace prefix where appropriate.  Use if running against an org with the managed package installed.  Defaults to False"
        },
        "namespaced_org": {
            "description": "If True, attempts to prefix all unmanaged metadata references with the namespace prefix for deployment to the packaging org or a namespaced scratch org.  Defaults to False"
        },
    }
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / org_settings.py View on Github external
"""
ORGPREF = """
    {name}
    {value}
"""
PACKAGE_XML = """

    
        *
        Settings
    
    46.0
"""


class DeployOrgSettings(Deploy):
    task_doc = """Deploys org settings from an sfdx scratch org definition file."""

    task_options = {
        "definition_file": {"description": "sfdx scratch org definition file"}
    }

    def _run_task(self):
        with open(self.options["definition_file"], "r") as f:
            scratch_org_definition = json.load(f)

        settings = scratch_org_definition.get("settings", {})
        if not settings:
            return

        with temporary_dir() as path:
            self._generate_package(settings)
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce.py View on Github external
return

        for item in sorted(os.listdir(path)):
            item_path = os.path.join(path, item)
            if not os.path.isdir(item_path):
                continue

            self.logger.info('Deploying bundle: {}/{}'.format(self.options['path'], item))

            self._deploy_bundle(item_path)

    def _deploy_bundle(self, path):
        api = self._get_api(path)
        return api()

deploy_namespaced_options = Deploy.task_options.copy()
deploy_namespaced_options.update({
    'managed': {
        'description': 'If True, will insert the actual namespace prefix.  Defaults to False or no namespace',
    },
    'namespace': {
        'description': 'The namespace to replace the token with if in managed mode. Defaults to project__package__namespace',
    },
    'namespaced_org': {
        'description': "If True, the tokens %%%NAMESPACED_ORG%%% and ___NAMESPACED_ORG___ will get replaced with the namespace.  The default is false causing those tokens to get stripped and replaced with an empty string.  Set this if deploying to a namespaced scratch org or packaging org.",
    },
    'namespace_token': {
        'description': 'The string token to replace with the namespace.  Defaults to %%%NAMESPACE%%%',
    },
    'filename_token': {
        'description': 'The path to the parent directory containing the metadata bundles directories. Defaults to ___NAMESPACE___',
    },
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce.py View on Github external
def _process_meta_xml(self, zipf):
        if not process_bool_arg(self.options.get('clean_meta_xml', True)):
            return zipf

        self.logger.info(
            'Cleaning meta.xml files of packageVersion elements for deploy'
        )
        zipf = zip_clean_metaxml(zipf, logger=self.logger)
        return zipf

    def _write_zip_file(self, zipf, root, path):
        zipf.write(os.path.join(root, path))


class CreatePackage(Deploy):
    task_options = {
        'package': {
            'description': 'The name of the package to create.  Defaults to project__package__name',
            'required': True,
        },
        'api_version': {
            'description': 'The api version to use when creating the package.  Defaults to project__package__api_version',
            'required': True,
        },
    }

    def _init_options(self, kwargs):
        super(CreatePackage, self)._init_options(kwargs)
        if 'package' not in self.options:
            self.options['package'] = self.project_config.project__package__name
        if 'api_version' not in self.options:
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / UninstallPackage.py View on Github external
from cumulusci.core.utils import process_bool_arg
from cumulusci.salesforce_api.package_zip import UninstallPackageZipBuilder
from cumulusci.tasks.salesforce import Deploy


class UninstallPackage(Deploy):
    task_options = {
        "namespace": {
            "description": "The namespace of the package to uninstall.  Defaults to project__package__namespace",
            "required": True,
        },
        "purge_on_delete": {
            "description": "Sets the purgeOnDelete option for the deployment.  Defaults to True",
            "required": True,
        },
    }

    def _init_options(self, kwargs):
        super(UninstallPackage, self)._init_options(kwargs)
        if "namespace" not in self.options:
            self.options["namespace"] = self.project_config.project__package__namespace
        self.options["purge_on_delete"] = process_bool_arg(
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce.py View on Github external
'required': True,
        },
    }

    def _init_options(self, kwargs):
        super(CreatePackage, self)._init_options(kwargs)
        if 'package' not in self.options:
            self.options['package'] = self.project_config.project__package__name
        if 'api_version' not in self.options:
            self.options['api_version'] = self.project_config.project__package__api_version

    def _get_api(self, path=None):
        package_zip = CreatePackageZipBuilder(self.options['package'], self.options['api_version'])
        return self.api_class(self, package_zip(), purge_on_delete=False)

class InstallPackageVersion(Deploy):
    task_options = {
        'namespace': {
            'description': 'The namespace of the package to install.  Defaults to project__package__namespace',
            'required': True,
        },
        'version': {
            'description': 'The version of the package to install.  "latest" and "latest_beta" can be used to trigger lookup via Github Releases on the repository.',
            'required': True,
        },
        'retries': {
            'description': 'Number of retries (default=5)',
        },
        'retry_interval': {
            'description': 'Number of seconds to wait before the next retry (default=5),'
        },
        'retry_interval_add': {
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce / DeployBundles.py View on Github external
import os

from cumulusci.tasks.salesforce import Deploy


deploy_options = Deploy.task_options.copy()
deploy_options["path"][
    "description"
] = "The path to the parent directory containing the metadata bundles directories"


class DeployBundles(Deploy):
    task_options = deploy_options

    def _run_task(self):
        path = self.options["path"]
        pwd = os.getcwd()

        path = os.path.join(pwd, path)

        self.logger.info("Deploying all metadata bundles in path {}".format(path))
github SFDO-Tooling / CumulusCI / cumulusci / tasks / salesforce.py View on Github external
api = self.api_class(self, package_zip, purge_on_delete=self.options['purge_on_delete'])
        return api()

    def _uninstall_dependency(self, dependency):
        self.logger.info('Uninstalling {}'.format(dependency['namespace']))
        package_zip = UninstallPackageZipBuilder(
            dependency['namespace'],
            self.project_config.project__package__api_version,
        )
        api = self.api_class(self, package_zip(), purge_on_delete=self.options['purge_on_delete'])
        return api()

deploy_options = Deploy.task_options.copy()
deploy_options['path']['description'] = 'The path to the parent directory containing the metadata bundles directories'
class DeployBundles(Deploy):
    task_options = deploy_options

    def _run_task(self):
        path = self.options['path']
        pwd = os.getcwd()

        path = os.path.join(pwd, path)

        self.logger.info(
            'Deploying all metadata bundles in path {}'.format(path))

        if not os.path.isdir(path):
            self.logger.warn('Path {} not found, skipping'.format(path))
            return

        for item in sorted(os.listdir(path)):