Using custom run Actions implemented in shared library

36 views
Skip to first unread message

Андрей Веселов

unread,
Dec 12, 2024, 7:14:20 AM12/12/24
to jenkins...@googlegroups.com
Hi everyone,

I have defined some custom action in my shared library like this (class whitelisted via -Dhudson.remoting.ClassFilter JAVA_OPTS)

```groovy
@ExportedBean(defaultVisibility = 2)
class CustomAction implements Action, Serializable {
    private String someData

    CustomAction(String someData) {
        this.someData = someData
    }

    // ...
}
```

and library function(to be used then in scripted pipelines)

```groovy
// setCustomAction
 
@NonCPS
void call(String data) {
    currentBuild.rawBuild.addAction(new CustomAction(data))
}
```

This allows me to expose some specific data which I can read then via build api.
But unfortunately CustomAction instances added to builds with this function leads to memory leak and Jenkins crash at the end. I found thousands of those objects in heapdump, they are never cleaned by GC. 

Is this a valid(enough) way to use Action?
Is there some obvious reason(for more skilled Jenkins developers) why this implementation is bad?
Any idea why those instances are stuck in memory after builds complete and actions provided by plugins are not?


Regards,
Andrey
Reply all
Reply to author
Forward
0 new messages