Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/hudson/plugins/gradle/BuildScanAction.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package hudson.plugins.gradle;

import hudson.model.Action;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@ExportedBean
public class BuildScanAction implements Action {

// Backward compatibility for old plugins versions which created an action per-scan
Expand All @@ -32,6 +35,7 @@ public void addScanUrl(String scanUrl) {
scanUrls.add(scanUrl);
}

@Exported
public List<String> getScanUrls() {
return Collections.unmodifiableList(scanUrls);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ class BuildScanIntegrationTest extends AbstractIntegrationTest {
new URL(action.scanUrls.get(0))
}

def 'build scan action is exposed via rest API'() {
given:
gradleInstallationRule.gradleVersion = '3.4'
gradleInstallationRule.addInstallation()
FreeStyleProject p = j.createFreeStyleProject()
p.buildersList.add(buildScriptBuilder())
p.buildersList.add(new Gradle(tasks: 'hello', gradleName: '3.4', switches: '-Dscan --no-daemon'))


when:
def build = j.buildAndAssertSuccess(p)

then:
println JenkinsRule.getLog(build)

def json = j.getJSON("${build.url}/api/json?tree=actions[*]")
def scanUrls = json.getJSONObject().get('actions').get(1).get('scanUrls')
scanUrls.size() == 1
new URL(scanUrls.get(0))
}

private static String getGradleEnterpriseConfiguration() {
"""<gradleEnterprise
xmlns="https://www.gradle.com/gradle-enterprise-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down