Support parameterized logic with IP ranges.
complete
Nathan Fish
complete
This has now been released.
Thomas Linderdahl
Nathan Fish Thanks a lot! Is it documented anywhere?
Nathan Fish
Thomas Linderdahl looks like docs missed getting updated. I'll take care of that now but here's an example from the changelog entry.
jobs:
job_a:
executor: base
circleci_ip_ranges: << pipeline.parameters.ip_ranges >>
steps:
- run: echo "Running job a"
Nicholas Shaw
If this feature were implemented, it would save us 160 lines of duplicated code. For example, say we need two of six workflows to use IP ranges, we now need to maintain two copies of a job, one the original and one for restricted IPs.
A parameter would avoid this duplication and is how I expected the IP ranges feature to work before diving into it.
Nathan Fish
Question Thomas Linderdahl on this? What type of rules do you want to base this on? Can you provide some examples of parameters you would like to see supported? Would existing pipeline values work (https://circleci.com/docs/pipeline-variables/#pipeline-values)?
Thomas Linderdahl
Nathan Fish I'm not extremely well versed in circleci so I'll try to explain the usecase and hopefully that answers your question.
We use a homebrew orb in our pipelines. In some of our pipelines we need circleci_ip_ranges enabled for a specific job and in other pipelines we don't. We'd like to set this as an input parameter in the pipeline config like below. Hope that helps.
version: 2.1
orbs:
myord: orb@1.0
workflows:
version: 2
my_workflow:
- myorb/jobname:
enableips: true
Nathan Fish
Thomas Linderdahl my thought is possible enabling this to support expression based evaluation (like our expression based contexts) so you can evaluate based on pipeline parameters as well. So it would add a bit more dynamic nature to the feature.
Thomas Linderdahl
Nathan Fish Sorry for slow response! That would allow setting this per pipeline/repo, correct? Sounds good enough to me.