Automatically tag commit after build (OD-2599)
Antoine Thiry opened 2 months ago

Hello there,

I have a really nice pipeline setup to automatically release my Unity packages to our npm repository when I make changes to the package.json npm file. But there is one improvement I would like to have so I don't have to do it manually but I didn't find how to do it yet or if it is even possible.

Right now, the build pipeline detects a version change in the package.json file in my repository and triggers the npm publish command to push it automatically, which is quite nice. But I would like to tag those commits with the current version that is in the package.json file.

Is it possible to do this with OneDev? Like is it possible to write to a variable in the publish step, and then read it in another build step ?

  • Robin Shen commented 2 months ago

    You may read version from package.json and write it to a file inside job workspace, say buildVersion, then add a create tag step with tag name set to @file:buildVersion

  • Antoine Thiry commented 2 months ago

    Yep thanks it worked! For future reference I will just add that I had to write the version to the job workspace by using the $ONEDEV_WORKSPACE env var:

    sed 's/.*"version": "\(.*\)".*/\1/;t;d' ./package.json > "$ONEDEV_WORKSPACE"/buildversion
    

    I was then able to use @file:buildversion@ in a seperate step

  • Robin Shen commented 2 months ago

    Thanks for sharing

  • Robin Shen changed state to 'Closed' 2 months ago
    Previous Value Current Value
    Open
    Closed
issue 1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2599
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover