forked from dalalv/jenkinsfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitcommit.groovy
More file actions
17 lines (15 loc) · 806 Bytes
/
gitcommit.groovy
File metadata and controls
17 lines (15 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Orig Ref From :: https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/gitcommit/gitcommit.groovy
// These should all be performed at the point where you've
// checked out your sources on the slave. A 'git' executable
// must be available.
// Most typical, if you're not cloning into a sub directory
sh('git rev-parse HEAD > GIT_COMMIT')
git_commit=readFile('GIT_COMMIT')
// short SHA, possibly better for chat notifications, etc.
short_commit=git_commit.take(6)
//create a GIT_COMMIT file in workspace and read back into a string in Pipeline
// If you have your sources checked out in a 'src' subdir
sh('cd src && git rev-parse HEAD > GIT_COMMIT')
git_commit=readFile('src/GIT_COMMIT')
// short SHA, possibly better for chat notifications, etc.
short_commit=git_commit.take(6)