Source:
void CreateRelease( ReleaseManagementHttpClient releaseManagementHttpClient, ReleaseDefinition releaseDefinition, String jobName, String buildNumber, int buildId, BuildListener listener, AbstractBuild<?, ?> build, Launcher launcher) throws ReleaseManagementException, JSONException { Artifact jenkinsArtifact = null; for(final Artifact artifact : releaseDefinition.getArtifacts()) { if(artifact.getType().equalsIgnoreCase("jenkins") && artifact.getDefinitionReference().getDefinition().getName().equalsIgnoreCase(jobName)) { jenkinsArtifact = artifact; break; } } if(jenkinsArtifact == null) { listener.getLogger().printf("No jenkins artifact found with name: %s%n", jobName); } else { List<ReleaseArtifact> releaseArtifacts = PrepareReleaseArtifacts( releaseDefinition, jenkinsArtifact, buildNumber, buildId, listener, releaseManagementHttpClient); String description = "Triggered by " + buildNumber; ReleaseBody releaseBody = new ReleaseBody(); releaseBody.setDescription(description); releaseBody.setDefinitionId(releaseDefinition.getId()); releaseBody.setArtifacts(releaseArtifacts); releaseBody.setIsDraft(false); String body = new Gson().toJson(releaseBody); listener.getLogger().printf("Triggering release...%n"); String response = releaseManagementHttpClient.CreateRelease(this.projectName, body); listener.getLogger().printf("Successfully triggered release.%n"); JSONObject object = new JSONObject(response); listener.getLogger().printf("Release Name: %s%n", object.getString("name")); listener.getLogger().printf("Release id: %s%n", object.getString("id")); String logLink = this.collectionUrl + this.projectName + "/_release?releaseId=" + object.getString("id") + "&_a=release-logs"; build.addAction(new LogSummaryAction(jobName, buildId, logLink)); } }

Target:
void CreateRelease( ReleaseManagementHttpClient releaseManagementHttpClient, ReleaseDefinition releaseDefinition, String jobName, String buildNumber, int buildId, BuildListener listener, AbstractBuild<?, ?> build, Launcher launcher) throws ReleaseManagementException, JSONException { Artifact jenkinsArtifact = null; for(final Artifact artifact : releaseDefinition.getArtifacts()) { if(artifact.getType().equalsIgnoreCase("jenkins") && artifact.getDefinitionReference().getDefinition().getName().equalsIgnoreCase(jobName)) { jenkinsArtifact = artifact; break; } } if(jenkinsArtifact == null) { listener.getLogger().printf("No jenkins artifact found with name: %s%n", jobName); } else { List<ReleaseArtifact> releaseArtifacts = PrepareReleaseArtifacts( releaseDefinition, jenkinsArtifact, buildNumber, buildId, listener, releaseManagementHttpClient); String description = "Triggered by " + buildNumber; ReleaseBody releaseBody = new ReleaseBody(); releaseBody.setDescription(description); releaseBody.setDefinitionId(releaseDefinition.getId()); releaseBody.setArtifacts(releaseArtifacts); releaseBody.setIsDraft(false); String body = new Gson().toJson(releaseBody); listener.getLogger().printf("Triggering release...%n"); String response = releaseManagementHttpClient.CreateRelease(this.projectName, body); listener.getLogger().printf("Successfully triggered release.%n"); JSONObject object = new JSONObject(response); listener.getLogger().printf("Release Name: %s%n", object.getString("name")); listener.getLogger().printf("Release id: %s%n", object.getString("id")); build.addAction(new ReleaseSummaryAction(jobName, buildId, object.getJSONObject("_links").getJSONObject("web").getString("href"))); } }