Get list of commits messages since previous build in an Azure Devops Pipeline custom extension task

Viewed 414

I'm implementing a custom extension in which I need to get the list of commit messages since the previous build in an Azure Devops Pipeline.

Build n (commit n, commit n-1)
Build n-1 (commit n-2, commit n-3)

This answer points at the Build.SourceVersionMessage as a way to get the commit message. I tried it but it only references the last commit commit n, instead of commit n, commit n-1:

          - task: MyTask@0
            inputs:
              commitMessage: '$(Build.SourceVersionMessage)'
import tl = require('azure-pipelines-task-lib/task');

async function run() {
    try {
        const commitMessage = tl.getInput("commitMessage", true) as string
        console.log('commitMessage', commitMessage);
    } catch (err) {
        tl.setResult(tl.TaskResult.Failed, err.message);
    }
}

run();

How can I get all the messages since the previous build?

0 Answers
Related