-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-53535] Make Bitbucket Server, Owner and repository environment variables for Bitbucket Team/Project based jobs #949
Conversation
505d307
to
da0a382
Compare
It looks like neither buildEnv.groovy nor buildEnv.jelly are considered to contribute the "Pipeline Syntax -> Global Variables Reference". I was looking around when I read this comment of @jglick in a resource file. @MarkEWaite Is this feature not yet enabled for those who extend GitSCMExtension.populateEnvironmentVariables? |
1fb669f
to
ba76107
Compare
…nt variables for Bitbucket Team/Project based jobs Add as environment variables some bitbucket useful informations like: - repository name (slug); - owner name (slug); - project key; - the server URL.
ba76107
to
72753d2
Compare
…nt variables for Bitbucket Team/Project based jobs (#949) Add as environment variables some bitbucket useful informations like: - repository name (slug); - owner name (slug); - project key; - the server URL.
Documentation will be available when JENKINS-75072 will be implemented |
@nfalco79 Thank you for the nice feature! When are these environment variables populated? I just updated to the latest master For PRs there already was the |
Are contributed but git extensions that means after a Just to be frank I had test only in branch 933.x, let me see if using new git-plugin works as expected |
@SunMar it was my fault! When I cherry pick the commit into master I failed to resolve conflicts, the BitbucketEnvVarExtension it's never instantiated. |
@nfalco79 yes it works now, thank you! |
@nfalco79 it works but when examining my Jenkins controller logs (for something unrelated) I noticed this come by for every build:
It's a warning and everything works, also the BITBUCKET_OWNER variable is populated with the same value as the project key. Not sure if that "owner" is the same as the one from the warning though. EDIT: here is the full stack trace:
|
|
||
def l = namespace(lib.JenkinsTagLib) | ||
|
||
// Base on javadoc in EnvironmentContributor Jenkins provides other extension points (such as SCM) to contribute environment variables to builds, and for those plugins, Jenkins also looks for /buildEnv.groovy and aggregates them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this file actually work? I cannot think how it would.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does not. Seems buildEnv.groovy is ignored for GitSCMExtension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have create this https://issues.jenkins.io/browse/JENKINS-75072
private final String projectKey; | ||
private final String serverURL; | ||
|
||
public BitbucketEnvVarExtension(@Nullable String owner, @NonNull String repository, @Nullable String projectKey, @NonNull String serverURL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing getters, and @DataBoundConstructor
, and a Descriptor
. Does this actually work? It does not look like it would.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works, also other GitSCMExtension in this plugin works without @DataBoundConstructor
Anyway In master I have added this annotation and descriptor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it works because XStream is able to build the object using reflection without use constructor (unsafe class) and inject fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As example the GitClientAuthenticatorExtension won't work with @DataBoundConstructor
. It fails with
Could not instantiate arguments for com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl. Secrets are involved, so details are available on more verbose logging levels.
Add as environment variables some bitbucket useful informations like: