Skip to content

Commit

Permalink
[JENKINS-47972] fix ClaimConfig circular dependency on data migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Greybird committed Dec 24, 2017
1 parent 48e857d commit 5bf7f4d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/hudson/plugins/claim/ClaimConfig.java
Expand Up @@ -133,7 +133,16 @@ public SecureGroovyScript getGroovyTrigger() {
}

void setGroovyTrigger(@Nonnull SecureGroovyScript groovyTrigger) {
this.groovyTrigger = groovyTrigger.configuring(ApprovalContext.create().withCurrentUser().withKey(GROOVY_SCRIPT_KEY)); }
this.setGroovyTrigger(groovyTrigger, true);
}

private void setGroovyTrigger(@Nonnull SecureGroovyScript groovyTrigger, boolean withCurrentUser ) {
ApprovalContext approvalContext = ApprovalContext.create().withKey(GROOVY_SCRIPT_KEY);
if (withCurrentUser) {
approvalContext = approvalContext.withCurrentUser();
}
this.groovyTrigger = groovyTrigger.configuring(approvalContext);
}

public boolean hasGroovyTrigger() {
return StringUtils.isNotEmpty(groovyTrigger.getScript());
Expand All @@ -150,7 +159,7 @@ public static ClaimConfig get() {
@SuppressWarnings("deprecation")
private Object readResolve() {
// JENKINS-43811 migration logic
setGroovyTrigger(new SecureGroovyScript(groovyScript != null ? groovyScript : "", true, null)); return this;
setGroovyTrigger(new SecureGroovyScript(groovyScript != null ? groovyScript : "", true, null), false); return this;
}

}

0 comments on commit 5bf7f4d

Please sign in to comment.