You can just use an sh
to execute the command. If you are using declarative syntax (starting with pipeline
instead of node
) I'd suggest to do that in the environment
, so you can read the result in all stages of your pipeline:
environment {
COMMIT = sh(script: '{ git log -1 --pretty=format:\'%an\'; echo "@xyzcompany.com, developer@xyzcompany.com"; } | xargs -I{} echo {} | sed \'s/\n//\'', returnStdout: true).trim()
}
Or –if you use scripted syntax– you just declare a variable:
def commit = sh(script: '{ git log -1 --pretty=format:\'%an\'; echo "@xyzcompany.com, developer@xyzcompany.com"; } | xargs -I{} echo {} | sed \'s/\n//\'', returnStdout: true).trim()