Table of Contents

zkbuild on Bitbucket Pipelines

Bitbucket Pipelines builds and tests a TwinCAT project through the Zeugwerk pipe docker://zeugwerk/zkbuild-pipe:latest. The pipe calls the same CI/CD backend as zkbuild on GitHub Actions. Shared behavior (artifacts, the deployment installer, pricing) is on the zkbuild reference.

Free tier for public repos (30 builds/month). For private repos or higher volume, contact us.


Quick start

  1. Register at api.zeugwerk.dev/account/register. Public repositories get 30 free builds per month.

  2. Store credentials. In the repository (or the workspace) open Pipelines → Repository variables and add:

    Variable Secured
    ZGWK_USERNAME
    ZGWK_PASSWORD_SECRET Yes

    Workspace variables are available to every repository in the workspace. Do not commit the password.

  3. Add a pipeline. Create bitbucket-pipelines.yml at the repository root (the example below).

  4. Configure the build. Add a .Zeugwerk/config.json. Generate it with Twinpack. Schema: config.json reference.

Pipeline file

Every branch is built and tested, including static analysis. Pull requests compile only, so feedback stays short. The pipe downloads the build archive into archive/ and copies test XML into test-results/. It fails the step when that XML reports failures.

image: atlassian/default-image:3

pipelines:
  default:
    - step:
        name: 'Zeugwerk Build & Test'
        script:
          - pipe: docker://zeugwerk/zkbuild-pipe:latest
            variables:
              USERNAME: $ZGWK_USERNAME
              PASSWORD: $ZGWK_PASSWORD_SECRET
              TCVERSION:       ''  # e.g. 'TC3.1.4026'. Blank selects a version automatically.
              WORKSPACE:       './'
              PLATFORM:        'TwinCAT RT (x64)'
              VARIANT_BUILD:   ''
              VARIANT_TEST:    ''
              STATIC_ANALYSIS: 'true'
              INSTALLER:       'false'
              SKIP_BUILD:      'false'
              SKIP_TEST:       'false'
              FORCE_CHECKS:    'false'
              ARTIFACT_NAME:   'artifact.zip'
        artifacts:
          - archive/**
          - test-results/**
        after-script:
          - pipe: atlassian/checkstyle-report:0.3.0
            variables:
              REPORT_FILES: 'test-results/*.xml'
              REPORT_TYPE: 'JUNIT'
              TITLE: 'Unit tests'
          - pipe: atlassian/checkstyle-report:0.3.0
            variables:
              REPORT_FILES: 'archive/**/*-checkstyle-result.xml'
              REPORT_TYPE: 'CHECKSTYLE'
              TITLE: 'Static Analysis'

  pull-requests:
    '**':
      - step:
          name: 'Zeugwerk Build (PR)'
          script:
            - pipe: docker://zeugwerk/zkbuild-pipe:latest
              variables:
                USERNAME: $ZGWK_USERNAME
                PASSWORD: $ZGWK_PASSWORD_SECRET
                TCVERSION:       ''
                WORKSPACE:       './'
                PLATFORM:        'TwinCAT RT (x64)'
                VARIANT_BUILD:   ''
                VARIANT_TEST:    ''
                STATIC_ANALYSIS: 'true'
                INSTALLER:       'false'
                SKIP_BUILD:      'false'
                SKIP_TEST:       'true'
                FORCE_CHECKS:    'false'
                ARTIFACT_NAME:   'artifact.zip'

Blank strings mean "use the default" (TwinCAT version chosen by the server, repository root, default PLC variant). Set INSTALLER: 'true' when you want the Windows deployment package described in PLC deployment installer.

Bitbucket has no paths: filter like GitHub Actions. Limit a pipeline to one directory with a custom: pipeline, or exit early after a git diff check.

Variables

Every value is a string. Booleans are 'true' or 'false'.

Variable Required Default Description
USERNAME Yes Zeugwerk account username. Pass $ZGWK_USERNAME.
PASSWORD Yes Zeugwerk account password. Pass $ZGWK_PASSWORD_SECRET.
PIPELINE_VERSION No main zkbuild pipeline version. Pin a tag from zkbuild-action for reproducible production builds. Leave it unset while onboarding.
TCVERSION No auto TwinCAT version, for example TC3.1.4024.22.
WORKSPACE No ./ Directory that contains .Zeugwerk. Use this when the project is not at the repository root.
VERSION No latest git tag Artifact version, for example 1.2.3 or 1.2.3-alpha.
VARIANT_BUILD No default variant PLC variant for the release build.
VARIANT_TEST No default variant PLC variant for unit tests. Typically a simulation variant without hardware.
PLATFORM No TwinCAT RT (x64) Target platform.
STATIC_ANALYSIS No false Run TwinCAT static analysis. Checkstyle XML is written into archive/.
INSTALLER No false Build the Windows deployment installer.
SKIP_BUILD No false Skip compilation and library artifacts.
SKIP_TEST No false Skip unit tests.
FORCE_CHECKS No false Run "Check All Objects" for application PLCs as well.
ARTIFACT_NAME No artifact.zip Downloaded archive name. Set a unique name when several build steps run in one pipeline.

The pipe also reads BITBUCKET_REPO_FULL_NAME, BITBUCKET_COMMIT, BITBUCKET_BRANCH, and BITBUCKET_PR_ID. You do not set those.

Artifacts and reports

Result Location
Libraries, logs, installer, checkstyle XML archive/
Unit test XML copied for reporting test-results/*.xml (taken from archive/tests)

List both globs under artifacts: so later steps and the Bitbucket download still see them after the script exits. after-script publishes JUnit into the Tests tab and checkstyle into the code report. Test layouts and result file names: Unit tests.

Troubleshooting

Symptom Likely cause Fix
Pipe fails before the build starts USERNAME or PASSWORD is empty Add ZGWK_USERNAME and secured ZGWK_PASSWORD_SECRET, and pass them as $ZGWK_USERNAME and $ZGWK_PASSWORD_SECRET.
Step fails after "Test failures detected" JUnit XML contains failures or errors Open test-results/ from the step artifacts.
Tests tab stays empty Report pipe did not run, or XML is missing Keep archive/** and test-results/** in artifacts:, and run atlassian/checkstyle-report with REPORT_TYPE: JUNIT from after-script.
Static analysis report is empty Analysis is off, or the glob does not match Set STATIC_ANALYSIS: 'true' and point REPORT_FILES at archive/**/*-checkstyle-result.xml.
Project not found .Zeugwerk is not at the repository root Set WORKSPACE to that directory.