-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add support for defining Task-wide environment variables #254
Comments
We may want to support that for the pipeline too. /kind design |
hm i wonder what we need to set up to get that to work - ill add the label manually for now 🤔 |
@vdemeester looks like @bkuschel 's request in #263 will take care of that! |
@abayer would it be possible to add a use case to this? |
I’ll come up with something concrete tomorrow. |
Ok, here's an attempt at a use case: A Pipeline is managed and run by a higher level tool (let's say Jenkins X in this example), in response to GitHub pull requests being opened. Various steps and Tasks within that Pipeline need to have some environment variables made available that will provide GitHub-specific information that can be used in the steps and Tasks to control or modify behavior. A concrete example of this could be passing the PR target repo and branch name, the PR repo's owner, etc. Rather than having to specify these environment variables on each step, it'd be much simpler to be able to specify the environment variables in one place - either on the Task or, if the env vars are relevant across the whole Pipeline, on the Pipeline itself. This admittedly also depends on the ability to pass in simple key/value string parameters to a PipelineRun, but I feel like that's being addressed elsewhere. If we want to construct an example that isn't concerned with parameterization in general, we could instead go with a Task that contains multiple steps, where each of those steps are running commands that utilize a single environment variable, say, a SonarQube URL. Rather than having to copy the same environment variable onto each step, we could define it (in a hardcoded fashion) on the Task, with the steps picking up that environment variable automatically. I'd envision this allowing you to override a Pipeline-defined environment variable on a Task or step, or a Task-defined environment variable on a step. |
/assign abayer |
Hm so info like this would come from the PipelineResources most likely 🤔 I could see making it so that all of the metadata about a Run is made available to the Tasks and steps involved in some form.
hmmm I do kinda feel like params are a better fit for this 🤔- especially since the steps still need to make use of that value somehow, whether it's via |
@bobcatfish See my PR at #496 - it properly propagates down the |
Closing this for now after discussion over in #496 and on Slack - for the use case that was driving this for Jenkins X, this is just a nice-to-have to decrease verbosity in the If anyone else should stumble upon this ticket and has their own reasons for wanting implicit/inherited environment variables supported for |
I've been thinking about this some more - and I've finally come around to the idea of Task level environment variables! (And I think there's a good chance seeing @abayer 's example translation b/w the Jenkins X yaml and the Task yaml helped convince me XD) Here is my thought process: If multiple steps in one I'd like it to be clear from looking at a
Also I think there might be something to think about here whether we want to expose more container spec attributes at the Task level such that they apply to all steps in a Task (similar to how in #714 (comment) I think we might want to make it possible to "template" a pod spec for a Runs) Also interesting in your thoughts @vdemeester @imjasonh @dlorenc ! |
Agreed !
Agreed too ! 👼
That's a good point, we would do more or less the same as |
ooo neat, TIL! |
Switch busybox images to UBI
Expected Behavior
In some triggering systems (e.g. Jenkins X) a lot of contextual information is provided via environment variables, for example:
It should be possible to provide all of this information to a PipelineRun and all Tasks ( / TaskRuns) and all of their steps that are invoked by a triggering system that wants to provide this information.
Actual Behavior
Environment variables can only be defined per step, which means that every single step of every single Task that is invoked needs to be explicitly provided with these values.
Additional Info
This is a fine line we tread! If we make global environment variables, then users can use these variables inside of their containers and we will have no idea what they are using and what they aren't.
On the other hand, if we don't, things can become painfully verbose.
🤔
The text was updated successfully, but these errors were encountered: