jenkinsci/bitbucket-branch-source-plugin

GIT_COMMIT, GIT_URL, and other info is not returned in scm object or environment variables

red8888 opened this issue · 3 comments

Jenkins and plugins versions report

Environment
Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

linux

Reproduction steps

  1. Build a pipeline with the bitbucket plugin

Expected Results

I'm having trouble finding this in documentation anywhere, but from what I have seen I should be getting environment variables like GIT_COMMIT and GIT_URL populated OR that info should be available in the scm object.

Actual Results

Scm object does not include git commit and I don't have any env vars that have this info.

Anything else?

I just want to confirm if this is expected behavior. I don't want to have to shell out to git to get the commit id, url, commit message, commit user, etc.

  1. Build a pipeline with the bitbucket plugin

Do you mean the Bitbucket plugin or the Bitbucket Branch Source plugin?

When using the Bitbucket Branch Source plugin, env.GIT_COMMIT and env.GIT_URL is available in a declarative pipeline. I believe this actually set outside of the plugin. However, it seems it's not available in a scripted pipeline or I'm doing some silly error in the pipeline.

hudson.plugins.git.GitSCM.checkout sets some environment variables:

hudson.plugins.git.GitSCM.buildEnvironment sets some environment variables:

I'm not sure in which situations GitSCM.buildEnvironment is called. It's conceivable that a scripted pipeline that runs a checkout step might get GIT_COMMIT from GitSCM.checkout but not GIT_URL.