GitLab CI/CD pipeline TemplateΒΆ

The capella2polarion library can be used in a CI/CD pipeline. For that the following template can be used inside the .gitlab-ci.yml file:

variables:
  CAPELLA2POLARION_DEBUG: "1"
  # Remember to set the following environment variables:
  # POLARION_HOST
  # POLARION_PAT
  # CAPELLA2POLARION_PROJECT_ID
  # CAPELLA2POLARION_CAPELLA_MODEL
  # CAPELLA2POLARION_SYNCHRONIZE_CONFIG
  # Optional flags:
  # CAPELLA2POLARION_FORCE_UPDATE - Simulate initial run
  # CAPELLA2POLARION_TYPE_PREFIX - Prefix for work item types
  # CAPELLA2POLARION_ROLE_PREFIX - Prefix for work item link roles
  # CAPELLA2POLARION_GENERATE_FIGURE_CAPTIONS - Generate captions for figures
  # CAPELLA2POLARION_GROUPED_LINKS_CUSTOM_FIELDS - Generate custom fields for links grouped by role

capella2polarion_synchronise_elements:
  needs:
    - job: update_capella_diagram_cache
      artifacts: true

  script:
    - pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}"
    - capella2polarion synchronize

We highly recommend using the diagram cache as a separate job and define it as a dependency in our template for that reason. The diagram cache artifacts have to be included in the capella2polarion job and its path must be defined in the CAPELLA2POLARION_CAPELLA_MODEL variable. A .gitlab-ci.yml with a capella2polarion synchronization job could look like this:

include:
    - remote: https://raw.githubusercontent.com/DSD-DBS/capella-dockerimages/${CAPELLA_DOCKER_IMAGES_REVISION}/ci-templates/gitlab/diagram-cache.yml
    - remote: https://raw.githubusercontent.com/DSD-DBS/capella-polarion/ci-templates/gitlab/synchronise_elements.yml

default:
    tags:
        - docker

workflow: # Control job triggering
    rules:
        - if: $CI_COMMIT_BRANCH == "main" # execution only on main

variables:
    CAPELLA_VERSION: 6.1.0
    ENTRYPOINT: model.aird
    CAPELLA2POLARION_PROJECT_ID: syncproj
    CAPELLA2POLARION_CAPELLA_MODEL: '{"path": "PATH_TO_CAPELLA", "diagram_cache": "./diagram_cache"}'
    CAPELLA2POLARION_SYNCHRONIZE_CONFIG: capella2polarion_config.yaml
    CAPELLA2POLARION_DEBUG: 1