Source code synchronization

4 minute readReference

Source code synchronization helps users who want to use DSL to store, manage, and author their automation as code, and also want to version, maintain, and control code in a source code management (SCM) tool. This functionality is useful for applying GitOps principles to software delivery automation.

Source code synchronization permissions

If a project containing the source code synchronization objects does not have adequate permissions set, all jobs called by polling triggers or webhooks fail with the following error:

None of the principals in this authentication context ('project: Electric Cloud', 'project: EC-Git-VERSION', 'project: SCM_PROJECT', 'project: EC-DslDeploy-VERSION') have modify privilege on systemObject 'projects'

To resolve this issue, the project containing the source code synchronization object or one of principals in the error message must be given change permissions rights on the system object project. Refer to the following table for specific principal access settings.

Table 1. User permission settings
Read Modify Execute Change permissions Actual

A principal cannot view or perform any actions on the SCM object.

A principal can only view SCM object.

A principal can view, create, modify, and delete SCM object.

A principal can view and run the SCM object.

A principal can view, create, and delete the SCM object.

A principal can view, create, modify, delete, and execute the SCM object.

For more information, refer to Access Control.

Adding a source code synchronization object

Before SCM-to-server synchronizations can begin, you must add an object that includes the details required to perform the synchronization.

To add a source code synchronization object:

  1. From the CloudBees navigation menu, select CloudBees CD/RO.

  2. From the CloudBees CD/RO main menu, navigate to Administration  Configurations  Source code synchronization.

  3. On the Source code synchronizations page, select Add source code synchronization.

  4. Complete the following options:

    Item

    Description

    Name

    A user-defined name for this synchronization.

    Project name

    A unique name for the synchronization project.

    Description (optional)

    A user-defined description to help you identify the synchronization.

    Type

    The type of SCM. Currently, git is the only supported type.

    Send from source

    Indicates that the synchronization occurs from the SCM to the server. This checkbox is selected by default. You cannot change it.

    Plugin configuration

    Select or type the name of the appropriate plugin configuration object for the EC-Git plugin. The configuration is displayed as a path name. For example, /projects/myProject/pluginConfigurations/myConfiguration

    Resource name

    The name of the resource to synchronize.

    Destination directory

    The directory on the agent where the local SCM repository is located.

    Repository

    The name of the repository that contains the assets to be synchronized with the server.

    Branch

    The name of the branch in the repository.

    Relative path (optional)

    The relative path. This is a path in your repository to the correct dsl file structure.

    Include objects

    The objects to include in the synchronization. Enter the path to each object on a separate line. If you enter objects in this field, only those objects are synchronized. If you leave this field blank, all objects are synchronized.

    Exclude objects

    The objects to exclude from the synchronization. Enter the path to each object on a separate line.

    Cleanup

    Select this option to delete the destination directory after the job runs.

    Ignore failures

    Select this option to ignore failures during the import of DSL files.

    Local mode

    Select this option to prevent files from being sent to the server with the help of the clientFiles argument of the evalDsl operation in local mode. This option is available only if the destination directory is accessible from the CD/RO server. In a clustered deployment, all CD/RO server nodes must have access to this directory.

    Additional DSL arguments

    Any additional arguments for the evalDsl call.

  5. Select Save changes.

    Now, you can configure a trigger for the synchronization.

Configuring a trigger for source code synchronization

Set up a trigger to enable source code synchronization to run automatically.

To configure a trigger:

  1. From the CloudBees navigation, select CloudBees CD/RO.

  2. From the CloudBees CD/RO main menu, navigate to Administration  Configurations  Source code synchronization.

  3. On the Source code synchronizations page, locate the synchronization object that you want to trigger.

  4. In the Actions column, select the three vertical dots.

  5. Select Configure trigger.

  6. On the Triggers dialog, select Add +.

  7. Enter a name for the trigger.

  8. Select the plugin for the trigger.

  9. Select Webhook or Polling as the trigger type.

    The EC-Bitbucket and Trigger-Property plugins are not supported for source code synchronization triggers.
  10. Select Next.

Running a source code synchronization manually

To run a synchronization manually:

  1. From the CloudBees navigation, select CloudBees CD/RO.

  2. From the CloudBees CD/RO main menu, navigate to Administration  Configurations  Source code synchronization.

  3. On the Source code synchronizations page, locate the synchronization object that you want to run.

  4. Select Run.

    After the synchronization runs, the run details are displayed.

Editing source code synchronization settings

To edit the synchronization settings:

  1. From the main menu, select Administration  Configurations  Source code synchronization.

  2. On the Source code synchronizations page, locate the synchronization object that you want to edit.

  3. In the Actions column, select the three vertical dots.

  4. Select Edit.

  5. Edit the appropriate fields.

  6. Select Save changes.

Enabling or disabling a source code synchronization trigger

To enable or disable a trigger:

  1. From the main menu, select Administration  Configurations  Source code synchronization.

  2. On the Source code synchronizations page, locate the synchronization object for which you want to enable or disable a trigger.

  3. In the Actions column, select the three vertical dots.

  4. Select Edit.

  5. Scroll down to the Enable trigger checkbox.

  6. Check or uncheck the checkbox to enable or disable the trigger.

  7. Select Save changes.

Viewing the runs for a source code synchronization object

To view runs for an object:

  1. From the CloudBees navigation, select CloudBees CD/RO.

  2. From the CloudBees CD/RO main menu, navigate to Administration  Configurations  Source code synchronization.

  3. On the Source code synchronizations page, locate the synchronization object for which you want to view runs.

  4. In the Actions column, select the three vertical dots.

  5. Select View runs.

Deleting source code synchronization

To delete a source code synchronization object:

  1. From the CloudBees navigation, select CloudBees CD/RO.

  2. From the CloudBees CD/RO main menu, navigate to Administration  Configurations  Source code synchronization.

  3. On the Source code synchronizations page, locate the synchronization object for which you want to view runs.

  4. In the Actions column, select the three vertical dots.

  5. Select Delete.