Skip to content

Commit

Permalink
chore: returning the build of the branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Jul 26, 2024
1 parent 194b5b9 commit 29126f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vars/ontrackCliLastPromotion.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def call(Map<String, ?> params = [:]) {
builds(project: $project, branch: $branch, buildBranchFilter: {count: 1, withPromotionLevel: $promotion}) {
id
name
branch {
name
}
releaseProperty { value }
gitCommitProperty { value }
}
Expand All @@ -43,6 +46,7 @@ def call(Map<String, ?> params = [:]) {
if (logging) {
println("[ontrack-cli-last-promotion] Build found for promotion ${promotion}")
println("[ontrack-cli-last-promotion] Build ID = ${build.id}")
println("[ontrack-cli-last-promotion] Build branch = ${build.branch.name}")
println("[ontrack-cli-last-promotion] Build name = ${build.name}")
println("[ontrack-cli-last-promotion] Build release = ${release}")
println("[ontrack-cli-last-promotion] Build commit = ${commit}")
Expand All @@ -51,6 +55,7 @@ def call(Map<String, ?> params = [:]) {
if (injectEnv) {
env.ONTRACK_BUILD_LAST_PROMOTION = 'true'
env.ONTRACK_BUILD_ID = build.id as String
env.ONTRACK_BUILD_BRANCH_NAME = build.branch.name as String
env.ONTRACK_BUILD_NAME = build.name
if (release) {
env.ONTRACK_BUILD_RELEASE = release
Expand Down
2 changes: 2 additions & 0 deletions vars/ontrackCliLastPromotion.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ This step returns a JSON object describing the build. It can be `null` if the bu
|-----------|--------|--------------------------------------------------------|
| `id` | String | ID of the build |
| `name` | String | Name of the build |
| `branch` | String | Name of the branch of the build |
| `release` | String | (optional) Release/label/version attached to the build |
| `commit` | String | (optional) Git commit full SHA attached to the build |

If the [`injectEnv`](#parameters) parameter is set to `true`, the following environment variables are injected:

* `ONTRACK_BUILD_LAST_PROMOTION` - `true` if the build is defined, `false` otherwise
* `ONTRACK_BUILD_ID` - ID of the build if defined
* `ONTRACK_BUILD_BRANCH_NAME` - name of the branch of the build if defined
* `ONTRACK_BUILD_NAME` - name of the build if defined
* `ONTRACK_BUILD_RELEASE` - release of the build if defined
* `ONTRACK_BUILD_COMMIT` - commit of the build if defined
Expand Down
5 changes: 5 additions & 0 deletions vars/ontrackCliLastPromotionByProject.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def call(Map<String, ?> params = [:]) {
) {
id
name
branch {
name
}
releaseProperty {
value
}
Expand All @@ -48,6 +51,7 @@ def call(Map<String, ?> params = [:]) {
if (logging) {
println("[ontrack-cli-last-promotion-by-project] Build found for promotion ${promotion}")
println("[ontrack-cli-last-promotion-by-project] Build ID = ${build.id}")
println("[ontrack-cli-last-promotion-by-project] Build branch = ${build.branch.name}")
println("[ontrack-cli-last-promotion-by-project] Build name = ${build.name}")
println("[ontrack-cli-last-promotion-by-project] Build release = ${release}")
println("[ontrack-cli-last-promotion-by-project] Build commit = ${commit}")
Expand All @@ -56,6 +60,7 @@ def call(Map<String, ?> params = [:]) {
if (injectEnv) {
env.ONTRACK_BUILD_LAST_PROMOTION = 'true'
env.ONTRACK_BUILD_ID = build.id as String
env.ONTRACK_BUILD_BRANCH_NAME = build.branch.name as String
env.ONTRACK_BUILD_NAME = build.name
if (release) {
env.ONTRACK_BUILD_RELEASE = release
Expand Down
2 changes: 2 additions & 0 deletions vars/ontrackCliLastPromotionByProject.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This step returns a JSON object describing the build. It can be `null` if the bu
| Property | Type | Description |
|-----------|--------|--------------------------------------------------------|
| `id` | String | ID of the build |
| `branch` | String | Name of the branch of the build |
| `name` | String | Name of the build |
| `release` | String | (optional) Release/label/version attached to the build |
| `commit` | String | (optional) Git commit full SHA attached to the build |
Expand All @@ -27,6 +28,7 @@ If the [`injectEnv`](#parameters) parameter is set to `true`, the following envi

* `ONTRACK_BUILD_LAST_PROMOTION` - `true` if the build is defined, `false` otherwise
* `ONTRACK_BUILD_ID` - ID of the build if defined
* `ONTRACK_BUILD_BRANCH_NAME` - name of the branch of the build if defined
* `ONTRACK_BUILD_NAME` - name of the build if defined
* `ONTRACK_BUILD_RELEASE` - release of the build if defined
* `ONTRACK_BUILD_COMMIT` - commit of the build if defined
Expand Down

0 comments on commit 29126f1

Please sign in to comment.