How to get groovy scripts running #2817
floris huisman opened 4 weeks ago

I have made and have some ideas todo for groovy script, but I cant seem to figure out how to get the scripts running. In admin -> groovyscripting I made a script to test a bit. How does the script get triggered to run. I thought there would be a "run" button or something. And/or trigger the scripts from a job configured in .onedev-buildspec.yml. But I dont see them listed in the "steps".

Are there any examples or hints as how to trigger these scripts?

  • floris huisman changed fields 4 weeks ago
    Name Previous Value Current Value
    Type
    Question
    Bug
    Affected Versions
    empty
    15.1.6
  • floris huisman changed fields 4 weeks ago
    Name Previous Value Current Value
    Type
    Bug
    Question
  • Robin Shen commented 4 weeks ago

    The groovy script is mainly used in two places:

    1. Used in issue custom field or build param to calculate choices or default value if hard-code values is not sufficient
    2. Used in various CI/CD job properties (for instance image or command field of a command step) to insert calcualted string via property interpolation syntax @scripts:<script name>@
  • Robin Shen commented 3 weeks ago

    Closing. Feel free to reopen if you have more questions

  • Robin Shen changed state to 'Closed' 3 weeks ago
    Previous Value Current Value
    Open
    Closed
  • floris huisman commented 2 weeks ago

    Well, I was thinking to script an auto-comment on the issue whenever a commit was received. But that might be a bit out of scope I reckon. Or would it still be possible?

    For now I created a cronjob that monitors the commits and posts a comment, mentioning the commit, via the API. Basicly mimicking the functionality that was once added and later removed again :-) Thinking to change it into a webhook listener tho.

  • floris huisman changed state to 'Open' 2 weeks ago
    Previous Value Current Value
    Closed
    Open
  • floris huisman commented 2 weeks ago

    updated so it is now using a job executor (server shell). A trigger set via .onedev-buildspec.yml executes a shell script on trigger "BranchUpdateTrigger". Params passing along the project_path and commit hash. The script filters the commit message for an issue #nr. Then uses the api to get the internal issueId to post the comment (via api), as a service user, stating the commit done by (the author) with a link to the diff commit. Will look into converting this python script into a groovy script.

  • Robin Shen commented 2 weeks ago

    OneDev tracks commits associated with issues automatically if the commit message contains something like this:

    Fixes #<issue number>
    

    And the result is:

    https://code.onedev.io/onedev/server/~issues/2813/commits

    The commit message pattern to fix a issue number can be customized via Administration / Issue Settings / Commit Message Fix Settings

  • floris huisman commented 2 weeks ago

    yes, that is a nice feature. But we're just really used to see how the flow inside an issue is with comments and commits in chronological order. And having the commit-comments in them is also helpful. Maybe it would be feasible to include that "fixing commits" tab like a toggle, just like activities and comments. Commit comments would then finish it off :-)
    But we're not hoping or waiting for that and implemented this workaround which works well enough.

  • Robin Shen commented 2 weeks ago

    I am closing this as I cannot help more on this.

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