jenkinsci / jenkinsci/durable-task-plugin

[JENKINS-75954] OnceRetentionStrategy - Enable for General Use via API

Open
#520 6 comments 0 reactions 0 assignees View on GitHub
component:durable-task-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
30
Forks
101
PR merge metrics
No merged PRs in 30d

Description

It's possible for external automation systems to use the REST API to create new agent configurations.  Unfortunately, they cannot choose the OnceRetentionStrategy because it has no DataBoundConstructor:

org.kohsuke.stapler.NoStaplerConstructorException: There's no @​DataBoundConstructor on any constructor of class org.jenkinsci.plugins.durabletask.executors.OnceRetentionStrategy 	at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:291) 	at org.kohsuke.stapler.RequestImpl.instantiate(RequestImpl.java:983) 	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:874) Caused: java.lang.IllegalArgumentException: Failed to instantiate class hudson.slaves.RetentionStrategy from {"stapler-class":"org.jenkinsci.plugins.durabletask.executors.OnceRetentionStrategy"} 

Here's the code:

https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/executors/OnceRetentionStrategy.java

Can anyone familiar with this code indicate if there are any barriers or complications to adding a DataBoundConstructor to it? It seems likely there's a reason it wasn't included by default.

Assuming adding it is not an option, would it be reasonable within DurableTask to expose a new OnceRetentionStrategy class which is bindable for such use cases?

---
Originally reported by solvingj, imported from: OnceRetentionStrategy - Enable for General Use via API


  • status: Open
  • priority: Minor
  • component(s): durable-task-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-09

Raw content of original issue

It's possible for external automation systems to use the REST API to create new agent configurations.  Unfortunately, they cannot choose the OnceRetentionStrategy because it has no DataBoundConstructor:



org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class org.jenkinsci.plugins.durabletask.executors.OnceRetentionStrategy 	at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:291) 	at org.kohsuke.stapler.RequestImpl.instantiate(RequestImpl.java:983) 	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:874) Caused: java.lang.IllegalArgumentException: Failed to instantiate class hudson.slaves.RetentionStrategy from {"stapler-class":"org.jenkinsci.plugins.durabletask.executors.OnceRetentionStrategy"} 


Here's the code:

https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/executors/OnceRetentionStrategy.java

Can anyone familiar with this code indicate if there are any barriers or complications to adding a DataBoundConstructor to it? It seems likely there's a reason it wasn't included by default.

Assuming adding it is not an option, would it be reasonable within DurableTask to expose a new OnceRetentionStrategy class which is bindable for such use cases?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.