Can't make git log with pretty=format works in gradle

Hello

I have a problem make git log with format works in gradle. Why gitLog2 works and gitLog is not. Both commands works if you run it from command line.

def gitLog() {

return ‘git log --pretty=format:’* %h: %s ’ master…HEAD’.execute().text.trim() }

def gitLog2() {

return ‘git log --pretty=oneline --abbrev-commit master…HEAD’.execute().text.trim() }

Looks like it is groovy related question. Any one can help?

You have single quotes within a single quoted string. Use double quotes instead.

eg:

def gitLog() {

return “git log --pretty=format:’* %h: %s ’ master…HEAD”.execute().text.trim()

}