-
Notifications
You must be signed in to change notification settings - Fork 35
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
RFC: var steps + local var sources #27
Conversation
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Love ThisThis single feature has enabled us to streamline so many of our pipelines. 🙏 Improvement....Maybe?I think one thing that could potentially make this better, at the risk of overcomplicating a simple file read, is support for For example, in our (GitLab) merge request pipelines we extract some meta info about the merge request ( What I want to do is load the merge request number ( Current ApproachTo do that, I have to first - task: extract-merge-request-info
config:
platform: linux
image_resource:
type: registry-image
source:
# any image with 'jq' will do, our mr resource happens to have it and will have already been pulled to the job container so just use it (for job speed)
repository: samcontesse/gitlab-merge-request-resource
inputs:
- name: merge-request
outputs:
- name: merge-request-info
run:
path: sh
args:
- -exc
- |
# extract the merge request number ---> merge-request-info/number
jq <merge-request/.git/merge-request.json '.iid' >> merge-request-info/number
# ...other attributes we may want (individually) now I can use - load_var: merge-request-number
file: merge-request-info/number I could of course clean this up a little and write it as an external task, but the indirection step is still there and is still more cruft than I'd like. Potential ImprovementIt would be smoother if I could give - load_var: merge-request-number
file: merge-request/.git/merge-request.json
filter: {jq: '.iid'} Other Increasing ComplexityThis would of course make |
@jgriff Cheers! Glad it's paying off already. :) Hmm, can't you already load the JSON content and access the - load_var: merge-request-number
file: merge-request/.git/merge-request.json
- put: foo
params: {id: ((.:merge-request-number.iid))} |
@vito ah I see, yes! Did not realize the var was navigable like that, very nice 👍 |
This is really great. This allowed me to remove a custom task whose job was just to create a json file that could be loaded as docker build_args (containing json like Earlier: plan:
- { get: repo_teaxrapi, trigger: true, params: { depth: 1 } } #git repo
- task: task_get_build_properties #With the sole purpose of generating a json file
...
outputs: [{name: build-props}]
- put: drepo_teaxrapi #Using type: docker-image
...
params:
build_args_file: build-props/docker_build_args.json Now: plan:
- { get: repo_docker-creds, trigger: true, params: { depth: 1 } }
- { get: repo_teaxrapi, trigger: true, params: { depth: 1, short_ref_format: "b-%s" } }
- { load_var: BUILD_VERSION, file: repo_teaxrapi/.git/short_ref }
- task: build #Using type registry-image to push, oci-build-task to build
...
params:
BUILD_ARG_BUILD_VERSION: ((.:BUILD_VERSION))
DOCKER_CONFIG: repo_docker-creds All this resulted in builds being 30% faster now. The only side effect of this change was having to inject docker credentials for multi-stage builds as they are now handled by oci-build-task. |
Hi guys, Great job on this feature, it really simplified our pipelines. A small improvement I can see would be to add a parameter to allow displaying the content of the file (thus, the value of the var) in the UI. It could be necessary in some cases. 👏 |
Please do not refuse this feature, extremely helpful. |
I also have to agree that this RFC is very useful and helped us to achieve some things that would have otherwise be overly complicated. Please keep it. |
Seconded. Dramatically cleaned up our pipeline. |
Guys? What about |
@lukasmrtvy That makes sense to me! Just need someone to write up an RFC showing how it'd work. I didn't have any immediate use cases in mind so I didn't include it, but it seems intuitive. Thanks everyone for the feedback! :) |
Rendered
Related to, but not dependent on #24.