Skip to content
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

automatic way to provide properties to commands in postBuildSteps #306

Open
steveej opened this issue Sep 30, 2024 · 4 comments
Open

automatic way to provide properties to commands in postBuildSteps #306

steveej opened this issue Sep 30, 2024 · 4 comments

Comments

@steveej
Copy link

steveej commented Sep 30, 2024

currently i have the following hardcoded

            props = lib.attrsets.genAttrs [
              "attr"
              "basename"
              "branch"
              "builddir"
              "builderid"
              "buildername"
              "buildnumber"
              "cacheStatus"
              "codebase"
              "drv_path"
              "event"
              "github.base.sha"
              "github.head.sha"
              "out_path"
              "owners"
              "project"
              "projectid"
              "projectname"
              "pullrequesturl"
              "repository"
              "revision"
              "scheduler"
              "status_name"
              "system"
              "virtual_builder_name"
              "virtual_builder_tags"
              "workername"
            ] (name: self.inputs.buildbot-nix.lib.interpolate "%(prop:${name})s");

this list is just copied and pasted from the properties i saw on the web UI, and surely diverges for other forges and maybe even other projects on github. having a machine-readable way at runtime with all available properties would be nice.

@Mic92
Copy link
Member

Mic92 commented Oct 1, 2024

Can this not be provided by the writer of postBuildSteps as needed? Maybe documenting known portable ones would be a nice addition to documentation.

@Mic92
Copy link
Member

Mic92 commented Oct 1, 2024

The variable that you posted, can you explain how this is going to be used in the actual post hook?

@steveej
Copy link
Author

steveej commented Oct 1, 2024

in this case i experimented with exposing these values as environment variables

   postBuildSteps = [
      {
        name = "post-build-step-test";
        environment =
          let
            props = lib.attrsets.genAttrs [
              "attr"
              "basename"
              # ...
            ] (name: self.inputs.buildbot-nix.lib.interpolate "%(prop:${name})s");
            props' = lib.attrsets.mapAttrs' (name: value: lib.nameValuePair "PROP_${name}" value) props;
          in
          props';

however, a preferred alternative that could be to write a single structured file (e.g. json or toml) that's discoverable via a single environment variable. this file could also include other namespaced information such as %(secret:..)s, %(kw:...)s, etc..

@MagicRB
Copy link
Contributor

MagicRB commented Oct 5, 2024

This is more to be done from the python side. As in we can by default expose all properties as environment variables or make it togglable per PBS (postbuildstep)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants