Skip to content

Commit cda0e15

Browse files
committed
Make commit message an input variable
1 parent 3a81688 commit cda0e15

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Tasks/UnityBuild/UnityBuildV3/task.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@
179179
"helpMarkDown": "The user mail to use when commiting changes.",
180180
"visibleRule": "projectVersioningCommitChanges = true"
181181
},
182+
{
183+
"name": "projectVersioningCommitChangesMessage",
184+
"type": "string",
185+
"label": "Commit message",
186+
"groupName": "versioning",
187+
"defaultValue": "Azure Pipelines Build - {{bundleVersion}}",
188+
"helpMarkDown": "The commit message. Valid placeholders are: {{bundleVersion}}, {{buildNumber}}",
189+
"visibleRule": "projectVersioningCommitChanges = true"
190+
},
182191
{
183192
"name": "projectVersioningCreateTag",
184193
"type": "boolean",

Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
projectVersioningBundleVersionMinorVariableName,
1111
projectVersioningBundleVersionModeVariableName,
1212
projectVersioningBundleVersionPatchVariableName,
13+
projectVersioningCommitChangesMessageVariableName,
1314
projectVersioningCommitChangesUserMailVariableName,
1415
projectVersioningCommitChangesUserNameVariableName,
1516
projectVersioningCommitChangesVariableName,
@@ -256,10 +257,24 @@ export class UnityVersioning {
256257
true
257258
)!;
258259

260+
let commitMessage = tl.getInput(
261+
projectVersioningCommitChangesMessageVariableName
262+
)!;
263+
264+
commitMessage = commitMessage.replace(
265+
"{{bundleVersion}}",
266+
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
267+
);
268+
269+
commitMessage = commitMessage.replace(
270+
"{{buildNumber}}",
271+
buildCode.toString()
272+
);
273+
259274
tl.execSync("git", ["config", "user.name", commitChangesUserName]);
260275
tl.execSync("git", ["config", "user.email", commitChangesUserMail]);
261276
tl.execSync("git", ["add", "."]);
262-
tl.execSync("git", ["commit", "-m Azure Pipelines Build"]);
277+
tl.execSync("git", ["commit", `-m ${commitMessage}`]);
263278

264279
// Since we pushed to the repository, does the user also want to create a tag?
265280
if (createTag) {

Tasks/UnityBuild/UnityBuildV3/variables.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export const projectVersioningCommitChangesUserNameVariableName =
3838
"projectVersioningCommitChangesUserName";
3939
export const projectVersioningCommitChangesUserMailVariableName =
4040
"projectVersioningCommitChangesUserMail";
41+
export const projectVersioningCommitChangesMessageVariableName =
42+
"projectVersioningCommitChangesMessage";
4143
export const projectVersioningCreateTagVariableName =
4244
"projectVersioningCreateTag";
4345
export const projectVersioningCreateTagPatternVariableName =

0 commit comments

Comments
 (0)