1

I followed this Trailhead module (Build an Automated CI/CD Pipeline with GitLab) and have successfully created an unlocked package that has a CI/CD pipeline.

There is this part (in the Trailhead module) in the in the .gitlab-ci.yml file that controls the version:

    # Increment package version number
    - echo $PACKAGE_NAME
    - PACKAGE_VERSION_JSON="$(eval sfdx force:package:version:list --concise --released --packages $PACKAGE_NAME --json | jq '.result | sort_by(-.MajorVersion, -.MinorVersion, -.PatchVersion, -.BuildNumber) | .[0] // ""')"
    - echo $PACKAGE_VERSION_JSON
    - IS_RELEASED=$(jq -r '.IsReleased?' <<< $PACKAGE_VERSION_JSON)
    - MAJOR_VERSION=$(jq -r '.MajorVersion?' <<< $PACKAGE_VERSION_JSON)
    - MINOR_VERSION=$(jq -r '.MinorVersion?' <<< $PACKAGE_VERSION_JSON)
    - PATCH_VERSION=$(jq -r '.PatchVersion?' <<< $PACKAGE_VERSION_JSON)
    - BUILD_VERSION="NEXT"
    - if [ -z $MAJOR_VERSION ]; then MAJOR_VERSION=1; fi;
    - if [ -z $MINOR_VERSION ]; then MINOR_VERSION=0; fi;
    - if [ -z $PATCH_VERSION ]; then PATCH_VERSION=0; fi;
    - if [ "$IS_RELEASED" == "true" ]; then MINOR_VERSION=$(($MINOR_VERSION+1)); fi;
    - VERSION_NUMBER="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$BUILD_VERSION"
    - echo $VERSION_NUMBER

After experimenting on it, I realized only minor version is incremented by 1 each time I install the package to Production.

I would like to know what is the best practice for managing major version, minor version, patch version and build version, given my pipeline very similar to the one described in the Trailhead module (Unit test, Integration test, Package Installment).

2

For production release, you need to have Package promote. sfdx force:package:promote command will help you to do promoting(which will mark it as released package and major version will be upgraded.

Other minor/patches, you need to define the process in your SDLC cycle.

Like for hotpatches you can update patch, if its released as minor version of the package you can update minor version. Build version for every developer build prepared for testing team.

PS: This is not mandatory to use the functions given in Trailhead. You can define your own script to have those numbers populated.

1
  • How come my major version always stays at zero even if I promote the package? Aug 18 '20 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.