-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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-48431] - Support both lightweight checkout AND build parameter #898
Conversation
@MarkEWaite seems the CI is a bit overzealous and thinks my SNAPSHOT build is a release 🤔 |
I just retested the combination of workflow-cps-plugin, workflow-multibranch-plugin, git-plugin and scm-api-plugin. |
@jetersen I've downloaded your PR and have a try as I wanted to upgrade my PR to last version of plugins. I think that you did not take into account the refspec that can be set with environment variables also. I don't see the code:
|
I'm also wondering weither you might add some .trim() (I had some case of configuration with " " at the end of the config that was failing the job) |
In the I took minimal effort to the PR. Also |
I'm testing in my environment with your PR + some changes.
|
what kind of traits do you have on? |
@jetersen When you configure a job pipeline and setup the Git Repository URL (In my case it is set to https://$ZUUL_URL/$ZUUL_PROJECT) then on advanced section you can setup the Name (For me it's empty. But in the code I've also expanded the config to evaluate the string with environment variables in case of it might be needed) and also Refspec (In my case it is set to $ZUUL_REF that definitively needs to be evaluated with environment variables) This works for me with your code + some changes related to the last lines "String refspec = expand(config.getRefspec(), env);":
Note that it is better to setup some trim() for headName and remoteName because they are included into a string that would fails the pipeline if some space are remaining (See line refspec = "+" + Constants.R_HEADS + headName + ":" + Constants.R_REMOTES + remoteName + "/" + headName;). I've removed the test before "GitSCM gitSCM = (GitSCM) scm;" because it was failing the compilation due to spotbug that complains about testing a variable that could not be null... |
the |
Yes that was my plan , making fewer changes 😅 |
.asList(new RefSpec( | ||
"+" + prefix + headName + ":" + Constants.R_REMOTES + remoteName + "/" | ||
+ headName))).execute(); | ||
headName = expand(headName, env).trim(); |
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 discovered that this doesn't behave in quite the same way for statically provided strings vs environment variables in that by expanding the variable here rather than earlier we're forgoing some of the input normalization being done above.
example:
*/master
will become refs/remotes/origin/master
(probably) whereas
${SOME_ENV_VAR}
whose value is */master
will become refs/remotes/origin/*/master
which will NPE a little later on in the code.
Obviously it's easy enough to just not include */ in the variable but it may also be worthwhile for variables and static strings to go through the same process of string normalization. 🤷
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.
*/master
vs master
does not make any difference when expansion is not used? I wonder why is it supported in non-expansion mode in this case. Perhaps keep expansion as implemented here and consider changing non-expansion version later?
#1305 resolves the issue once the required release of workflow-cps is available from jenkinsci/workflow-cps-plugin#577 |
JENKINS-48431 - Support both lightweight checkout AND build parameter
Add support for environment expand during lightweight checkout
Thanks for starting the work @tgatinea
I tried to reduce the amount of changes by removing duplication.
relates to
Checklist
Types of changes
Further comments
expand on #772 apparently I could not choose that as a base, so creating a new PR.