-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Ensure that scm env variables are set for declarative pipeline. #286
Conversation
Not sure why the test is failing. Is this maybe not running the pipeline within the context of a git repository? I suppose I have to pull in |
Related to #283 ? |
Yeah seems related, but not sure if that PR would make the scm variables available. I will test it out tomorrow though. |
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.
FYI the test is not passing
https://jenkins.gke.csanchez.org/blue/organizations/jenkins/jenkinsci%2Fkubernetes-plugin/detail/PR-286/1/tests
WorkflowRun b = p.scheduleBuild2(0).waitForStart(); | ||
assertNotNull(b); | ||
r.assertBuildStatusSuccess((r.waitForCompletion(b))); | ||
r.assertLogNotContains("GIT_COMMIT is null", b); |
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 should also check that log contains GIT_COMMIT is
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.
Will do.
@carlossg Yes I was not sure yesterday how to ensure the pipeline is set-up against a git repo so the scm step is actually being run, but will look into that today. |
@carlossg Fixed the tests. Let me know if I should do anything else. |
pom.xml
Outdated
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> <!-- KubernetesDeclarativeAgentTest --> |
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.
duplicated
@abayer would love your |
We got bit by this today. Building in k8s is ideal for some of our projects but not having access to SCM Environment Variables greatly complicates a few things for some of our teams. Are there plans to review this again and potentially merge it? Is there an issue I can follow that's tracking this? |
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.
Sorry, missed the review ping originally - looks good once the conflict is resolved
test is failing, maybe a merge issue |
why close it @Globegitter ? |
I had an issue in my Jenkins setup that I did not have access to
GIT_COMMIT
etc variables in my declarative pipeline. And it was a mystery to me as I have the latest versions of all plugins and that should be working. Turns out that the kubernetes declarative agant is not support it.I just copied some of the relevant bits of code from: https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/fd56764049461eca7c27a976446f5e053ea3aefe/pipeline-model-extensions/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/CheckoutScript.groovy as well as the corresponding test. There might be a better way of doing this but this is the first time for me writing any groovy and contributing to anything related to jenkins. Also for some reason I could not run the test locally. But I have compiled the plugin and tested it in our jenkins deployment. Finally the SCM env variables work again as expected.
Just let me know if I should improve anything anywhere, but would be great to get this fix in.