I'm unable to find a way to pass the GIT_COMMIT variable to the jenkins pipeline. There are two steps, first step checks out the repo and second step creates the codeql report. To publish the report I need the recent ccommit id from the repo and pass it in the shell command.
Asked
Active
Viewed 207 times
-2
-
1What is your code for retrieving from git? – Matthew Schuchard Jul 13 '22 at 11:09
-
I'm using pipeline syntax generated code for the checkout – tarun Jul 14 '22 at 06:17
1 Answers
0
Use something like this for checkout step:
def scm = checkout(...)
scm.each{ k, v -> env."${k}" = v }
All the env variables below will be set and can be used anywhere
GIT_BRANCH
GIT_CHECKOUT_DIR
GIT_COMMIT
GIT_PREVIOUS_COMMIT
GIT_PREVIOUS_SUCCESSFUL_COMMIT
GIT_URL

IonutS
- 151
- 7