Skip to content

Commit c48cecf

Browse files
authored
CBS to compute the name of the next release (#310)
* CBS to compute the name of the next release --------- Signed-off-by: Monvorath Phongpaibul <[email protected]>
1 parent d0668b2 commit c48cecf

File tree

2 files changed

+460
-5
lines changed

2 files changed

+460
-5
lines changed

Templates/Common-Backend-Scripts/README.md

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ Artifact Name | Description | Script details
133133
---------- | -----| -----------------------------------------------------
134134
[gitClone.sh](gitClone.sh) | Pipeline Shell Script to perform Git Clone to z/OS UNIX System Services | [script details](README.md#41---gitclonesh)
135135
[dbbBuild.sh](dbbBuild.sh) | Pipeline Shell Script to invoke the Dependency Based Build framework [zAppBuild](https://github.com/IBM/dbb-zappbuild) | [script details](#dbbbuildsh-for-zappbuild-frameworkh)
136-
[zBuilder.sh](zBuilder.sh) | Pipeline Shell script to invoke the zBuilder framework [zBuilder](https://www.ibm.com/docs/en/dbb/3.0?topic=building-zos-applications-zbuilder) | [script details](#zbuildersh-for-dbb-zbuilder)
136+
[zBuilder.sh](zBuilder.sh) | Pipeline Shell Script to invoke the zBuilder framework [zBuilder](https://www.ibm.com/docs/en/dbb/3.0?topic=building-zos-applications-zbuilder) | [script details](#zbuildersh-for-dbb-zbuilder)
137+
[computeReleaseVersion.sh](computeReleaseVersion.sh) | Pipeline Shell Script to compute the next release version based on the baseline version information stored in the application's [baselineReference.config](samples/baselineReference.config) file. | [script details](#computeReleaseVersionsh)
137138
[packageBuildOutputs.sh](packageBuildOutputs.sh) | Pipeline Shell Script to create a Package using the [PackageBuildOutputs groovy script](https://github.com/IBM/dbb/tree/main/Pipeline/PackageBuildOutputs) | [script details](#packagebuildoutputssh)
138139
[ucdPackage.sh](ucdPackaging.sh) | Pipeline Shell Script to publish to UCD Code Station binary repository using the [CreateUCDComponentVersion groovy script](https://github.com/IBM/dbb/tree/main/Pipeline/CreateUCDComponentVersion) | [script details](#ucdpackagingsh)
139140
[wazideploy-generate.sh](wazideploy-generate.sh) | Pipeline Shell Script to generate a Deployment Plan to be used with Wazi Deploy | [script details](#wazideploy-generatesh)
@@ -492,6 +493,84 @@ The [dbbzBuilderUtils](utilities/dbbzBuilderUtils.sh) script is a core utility s
492493
493494
Depending on the Deployment Manager tool you are using, you can choose from either creating a package with the [PackageBuildOutputs](#packagebuildoutputssh) script that can be used with IBM Wazi Deploy, or the [UCD packaging](#ucdpackagingsh) script that creates the UCD shiplist and UCD component version.
494495
496+
### computeReleaseVersion.sh
497+
498+
This script is to compute the version for the next release based on the information of baseline version stored in the [baseineReference.config](samples/baselineReference.config) file. The computation of the release version follows the versioning described in [IBM recommended Git branching model for mainframe developer](https://ibm.github.io/z-devops-acceleration-program/docs/branching/git-branching-model-for-mainframe-dev). It follows the Systematic Versioning as MAJOR.MINOR.PATCH number. The number of the coresponding part is increased based on the type of release.
499+
500+
The computed release version is used as part of the archive name to be uploaded or downloaded from the artifact repository. The release version is an input for [packageBuildOutputs.sh](#packagebuildoutputssh) and [wazideploy-generate.sh](#wazideploy-generatesh).
501+
502+
#### Invocation
503+
504+
The `computeReleaseVersion.sh` script can be invoked as follows:
505+
506+
```
507+
computeReleaseVersion.sh -w MortApp/main/build-1 -a MortgageApplication -b main -r minor
508+
```
509+
510+
CLI parameter | Description
511+
---------- | ----------------------------------------------------------------------------------------
512+
-w `<workspace>` | **Workspace directory**, an absolute or relative path that represents unique directory for this pipeline definition, that needs to be consistent through multiple steps.
513+
-a `<application>` | **Application name** to be built.
514+
-b `<branch>` | **Git branch** that is built.
515+
-r `<major/minor/patch>` | **Release Type** to indicate the type of changes to be relased.
516+
517+
#### Output
518+
519+
The section below contains the output that is produced by the `computeReleaseVersion.sh` script.
520+
521+
<details>
522+
<summary>Script Output</summary>
523+
524+
```
525+
+ computeReleaseVersion.sh -w /var/jenkins/workspace/tgageApplication-Pipelines2_main -a MortgageApplication -b main -r major
526+
[Pipeline] echo
527+
computeReleaseVersion.sh: [INFO] Release Version Wrapper. Version=1.10
528+
computeReleaseVersion.sh: [INFO] Reading pipeline configuration file: /var/jenkins/dbb/Templates/Common-Backend-Scripts/pipelineBackend.config
529+
computeReleaseVersion.sh: [INFO] Validating Options
530+
computeReleaseVersion.sh: [INFO] Application Directory: /var/jenkins/workspace/tgageApplication-Pipelines2_main/MortgageApplication
531+
computeReleaseVersion.sh: [INFO] Detected the application respository (MortgageApplication) within the git repository layout structure.
532+
computeReleaseVersion.sh: [INFO] Assuming this as the new application location.
533+
computeReleaseVersion.sh: [INFO] **************************************************************
534+
computeReleaseVersion.sh: [INFO] ** Started Next Release Computation on HOST/USER: z/OS ZT01 05.00 02 8561/
535+
computeReleaseVersion.sh: [INFO] ** Workspace: /var/jenkins/workspace/tgageApplication-Pipelines2_main/MortgageApplication
536+
computeReleaseVersion.sh: [INFO] ** Application: MortgageApplication
537+
computeReleaseVersion.sh: [INFO] ** Branch: main
538+
computeReleaseVersion.sh: [INFO] ** Release Type: major
539+
computeReleaseVersion.sh: [INFO] ** Baselinereference file: /var/jenkins/workspace/tgageApplication-Pipelines2_main/MortgageApplication/application-conf/baselineReference.config
540+
computeReleaseVersion.sh: [INFO] **************************************************************
541+
542+
computeReleaseVersion.sh: [INFO] Baseline reference: refs/tags/rel-1.6.0
543+
computeReleaseVersion.sh: [INFO] Compute the next release version complete. The next release version: rel-2.0.0. rc=0
544+
545+
```
546+
547+
</details>
548+
549+
#### Extract the next release version
550+
551+
To obtain the release version from the `computeReleaseVersion.sh` script's output log, utilize string manipulation commands within your pipeline orchestrator to search for the pattern `version: .*rc=0` pattern and extract the version number form the search result.
552+
553+
<details>
554+
<summary>Example snippet to extract the version number</summary>
555+
556+
```
557+
regexPattern = "version: .*rc=0"
558+
pattern = java.util.regex.Pattern.compile(regexPattern)
559+
//logContent is the output from invoking the computeReleaseVersion.sh script
560+
def pMatcher = pattern.matcher(logContent)
561+
if (pMatcher.find()) {
562+
def version = "${pMatcher.group()}"
563+
if (version){
564+
releaseVersion = version.substring(9,version.length()-6)
565+
}
566+
} else {
567+
println("[INFO]: Failed to search for ${regexPattern}")
568+
}
569+
570+
```
571+
572+
</details>
573+
495574
### packageBuildOutputs.sh
496575
497576
This script is to execute the `PackageBuildOutputs.groovy` that packages up the build outputs and optionally uploads it to an artifact repository to publish the artifacts created by a DBB build in the pipeline.
@@ -512,7 +591,8 @@ For release builds (that use the `pipelineType=release`), the archive is uploade
512591
`release/<reference>/<application>-<buildIdentifier>`:
513592
514593
* **release** is defined for release builds.
515-
* **reference** is the release name: for instance, `rel-1.2.3` (provided through the mandatory `-r` argument).
594+
* **reference** is the release name: for instance, `rel-1.2.3` (provided through the mandatory `-r` argument). The release name can be automatically computed using the [computeReleaseVersion.sh](#computereleaseversionsh) script.
595+
516596
The archive's file name is computed using the application's name, the release name (`-r` argument) and a unique build identifier (`-i` argument). This parameter is typically the pipeline build number that is passed by the pipeline orchestrator. If a build identifier is not provided, the current timestamp is used.
517597
518598
@@ -629,8 +709,6 @@ rc=0
629709
630710
</details>
631711
632-
633-
634712
### ucdPackaging.sh
635713
636714
This script is to execute the `dbb-ucd-packaging.groovy` that invokes the Urban Code Deploy (UCD) buztool utility, to publish the artifacts created by the DBB Build from a pipeline.
@@ -727,7 +805,7 @@ CLI parameter | Description
727805
-- | - when retrieving the tar file from Artifact repo the below options are mandatory -
728806
-b `<branch>`| Name of the **git branch** turning into a segment of the directory path for the location within the artifact repository.
729807
-p `<build/release>` | **Pipeline Type** to indicate a `build` pipeline (build only with test/debug options) or a `release` pipeline (build for optimized load modules for release candidates).
730-
-R `<releaseIdentifier>` | **Release identifier** to indicate the next planned release name. This is a computed value based on the pipeline templates.
808+
-R `<releaseIdentifier>` | **Release identifier** to indicate the next planned release name. This is a computed value based on the pipeline templates. It can be automatically computed using the [computeReleaseVersion.sh](#computereleaseversionsh) script.
731809
-I `<buildIdentifier>` | **Build identifier** a unique value to identify the tar file. This is a computed value provided by the pipeline templates. Typically the build number of the pipeline run.
732810
-c `<configurationFile>` | Absolute path to the Wazi Deploy **Configuration File** that contains information to connect to the artifact repository. See [IBM Wazi Deploy documentation](https://www.ibm.com/docs/en/developer-for-zos/17.0?topic=files-configuration-file)
733811

0 commit comments

Comments
 (0)