'Can't get all git commit message in tfs build

I'm building a CI build and want to get the git commit message from developers in order to parse it in my script.

I've added a batch command-line step and pass $(BUILD_SOURCEVERSIONMESSAGE) in the Argument edit box but I just not getting all the commit message.

The message is multi-line:

PR 231: ALGCQ-79343 Merge release-rsna to develop

  • PR 225: Merge layout_poc_2 to release-rsna
  • Add icons for RSNA
  • bug fix: dropdowns did not work on iPad.
  • remove direct reference to material design for PMA strip report/bookmark icons.
  • puzzlehead bugfix for RSNA ...

The text includes CRLF because it's an automatic message from the pull-request and what I get in the script is just the first 2 lines.

Because of that it also break the rest of the argument list which not being passed to the script.

I also tried to get the the message from environment variable in powershell script and got the same.

Is there any character lenth I dont know of? Doest someone know a way the get the full commit message and send it to a script?



Solution 1:[1]

From the docs:

The comment of the commit or changeset for the triggering repo. We truncate the message to the first line or 200 characters, whichever is shorter.

https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml&WT.mc_id=DOP-MVP-5001511#build-variables-devops-services

If you need the full message I suspect you'll need to run this git command in case you have the repo checked out on the agent.

git log --format=%B -n 1 <commit>

Or use the REST API to get the details for the commit.

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=6.0

https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get?view=azure-devops-rest-6.0&WT.mc_id=DOP-MVP-5001511

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1