pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.25k stars 623 forks source link

provide common dynamic git data to plugins #19981

Open cburroughs opened 10 months ago

cburroughs commented 10 months ago

Is your feature request related to a problem? Please describe.

As described in https://www.pantsbuild.org/docs/tagging-docker-images#using-env-vars-to-include-dynamic-data-in-tags I'd like common dynamic git data like the sha or branch name to be available in BUILD files so they can be used to construct docker tags and other versioned fields.

Describe the solution you'd like

An object (git?) available with properties like commit_id or branch_name.

Describe alternatives you've considered Fork off a bunch of processes in a shell as described in https://github.com/pantsbuild/pants/discussions/17633

Additional context

lilatomic commented 4 months ago

we can expose symbols in BUILD files with def build_file_aliases(): in a register.py. I'm not sure if we can invoke rules within that context, though.