Skip to content

agent: log injected version string at startup#5722

Closed
Utkarsh9571 wants to merge 5 commits into
woodpecker-ci:mainfrom
Utkarsh9571:agent-version-log
Closed

agent: log injected version string at startup#5722
Utkarsh9571 wants to merge 5 commits into
woodpecker-ci:mainfrom
Utkarsh9571:agent-version-log

Conversation

@Utkarsh9571
Copy link
Copy Markdown
Contributor

This patch adds a startup log line to the Woodpecker agent that prints the injected version string.

  • Uses -ldflags to inject Version at build time
  • Logs the version using zerolog in main.go
  • Helps validate build provenance and patch testing
  • Safe to merge; does not affect agent registration or backend handshake

Example output:
{"level":"info","message":"Woodpecker Agent Version: localtest"}

This supports contributor validation for Issue #5685.

@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

Utkarsh9571 commented Nov 6, 2025

Hi team! Just checking in on this patch — it adds a startup log line to the agent that prints the injected version string, helping validate build provenance and patch testing.

  • Scope: agent only
  • No impact on registration or backend handshake
  • Fully contributor-safe and reproducible

Would appreciate a quick review or workflow approval when possible. Thanks for your time!

@qwerty287
Copy link
Copy Markdown
Contributor

Thanks, but this doesn't look right. The version is stored at version/version.go.

@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

Utkarsh9571 commented Nov 6, 2025

@qwerty287 Thanks for the feedback! I've updated the patch to use version.String() from version/version.go for logging the agent version, as suggested. The custom Version variable and -ldflags logic have been removed for consistency.

Let me know if you'd like any further changes!

@qwerty287
Copy link
Copy Markdown
Contributor

qwerty287 commented Nov 6, 2025

Thanks, please revert any change that is not related.

  • Restore the docker example
  • remove the version.go file
  • use tabs instead of spaces.

Checkout the diff to see how your change currently looks like, then you'll see what's wrong.

Also, I'd put the log statement into cmd/agent/core/agent.go.

@qwerty287 qwerty287 added agent enhancement improve existing features labels Nov 6, 2025
@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

Utkarsh9571 commented Nov 6, 2025

@qwerty287 Thanks for the detailed feedback! I think i've made the required changes:

  • Moved the version log to cmd/agent/core/agent.go as requested
  • Removed version/version.go
  • Restored docker-compose.example.yaml
  • Reverted unrelated changes and ensured tab-based formatting with gofmt

Let me know if anything else needs adjustment!

@6543
Copy link
Copy Markdown
Member

6543 commented Nov 6, 2025

that was the wrong version.go i would say

now server and cli have no way of knowing what version they are 😅

@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

Utkarsh9571 commented Nov 6, 2025

@6543 yeah, thanks for pointing that out man. I misunderstood the version.go context — happy to restore version reporting properly. Would you prefer I reintroduce the version string via ldflags and wire it into the CLI output for both agent and server? I can patch that cleanly.

@6543
Copy link
Copy Markdown
Member

6543 commented Nov 6, 2025

it's already done so via our build chain just use it, doesnt have to be as complex ;)

@6543
Copy link
Copy Markdown
Member

6543 commented Nov 6, 2025

LDFLAGS := -X go.woodpecker-ci.org/woodpecker/v3/version.Version=${VERSION}

@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

Utkarsh9571 commented Nov 6, 2025

yeah, do you need me to do something else in this? i'm kinda new to open source, so don't know much how all that works.

@qwerty287
Copy link
Copy Markdown
Contributor

qwerty287 commented Nov 6, 2025

Just reverting all the changes except cmd/agent/core/agent.go should do it.

@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

@qwerty287 i made a commit, is it good now?

@qwerty287
Copy link
Copy Markdown
Contributor

Sorry, but no.

All the files in the diff (you can see that in the files tab) except cmd/agent/core/agent.go have to have the same content as in main. So this file must be the only one that's shown there.

@Utkarsh9571
Copy link
Copy Markdown
Contributor Author

Utkarsh9571 commented Nov 6, 2025

@qwerty287 bro, this branch is messed up, i created another branch and opened another pr #5724

so check that out

@qwerty287 qwerty287 closed this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent enhancement improve existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants