Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup after upgrade #80

Merged
merged 10 commits into from
Aug 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
writer.println(String.format("\t\t<repname>%s</repname>", escapeForXml(changeSet.getRepoName())));
writer.println(String.format("\t\t<repserver>%s</repserver>", escapeForXml(changeSet.getRepoServer())));
writer.println(String.format("\t\t<guid>%s</guid>", escapeForXml(changeSet.getGuid())));
if (changeSet.getItems().size() > 0) {
if (!changeSet.getItems().isEmpty()) {

Check warning on line 56 in src/main/java/com/codicesoftware/plugins/hudson/ChangeSetWriter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 56 is not covered by tests
writer.println("\t\t<items>");
for (ChangeSet.Item item : changeSet.getItems()) {
writer.println(String.format("\t\t\t<item revId=\"%s\" parentRevId=\"%s\" status=\"%s\">%s</item>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@

@Nonnull
String getWorkingModeParam() {
return "--workingmode=" + workingMode.getPlasticWorkingMode();
return workingMode == null ? "" : "--workingmode=" + workingMode.getPlasticWorkingMode();
}

@Nonnull
String getUserParam() {
return "--username=" + credentials.getUsername();
return credentials == null ? "" : "--username=" + credentials.getUsername();
}

@Nonnull
String getPasswordParam() {
return "--password=" + Secret.toString(credentials.getPassword());
return credentials == null ? "" : "--password=" + Secret.toString(credentials.getPassword());

Check warning on line 60 in src/main/java/com/codicesoftware/plugins/hudson/ClientConfigurationArguments.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 50-60 are not covered by tests
}

boolean hasWorkingModeManualValues() {
Expand Down
80 changes: 19 additions & 61 deletions src/main/java/com/codicesoftware/plugins/hudson/PlasticSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Computer;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.Job;
Expand All @@ -48,13 +46,12 @@
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.verb.POST;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -109,12 +106,10 @@

private final String selector;

private CleanupMethod cleanup;
private final CleanupMethod cleanup;
private final WorkingMode workingMode;
@CheckForNull
private final String credentialsId;
@Deprecated
private transient boolean useUpdate;

private final List<WorkspaceInfo> additionalWorkspaces;
private final WorkspaceInfo firstWorkspace;
Expand All @@ -130,7 +125,7 @@
String selector,
CleanupMethod cleanup,
WorkingMode workingMode,
String credentialsId,
@CheckForNull String credentialsId,
boolean useMultipleWorkspaces,
List<WorkspaceInfo> additionalWorkspaces,
boolean pollOnController,
Expand Down Expand Up @@ -161,620 +156,596 @@

@Exported
public CleanupMethod getCleanup() {
// Field might be null if deserialized from older class version.
return (cleanup != null) ? cleanup : CleanupMethod.convertUseUpdate(useUpdate);
return cleanup;
}

@Exported
public WorkingMode getWorkingMode() {
// Field might be null if deserialized from older class version.
return (workingMode != null) ? workingMode : WorkingMode.NONE;
}

@CheckForNull
@Exported
public String getCredentialsId() {
return credentialsId;
}

@Exported
public boolean isUseMultipleWorkspaces() {
return useWorkspaceSubdirectory;
}

@Exported
@SuppressWarnings("unused")
public List<WorkspaceInfo> getAdditionalWorkspaces() {
return additionalWorkspaces;
}

@Exported
public WorkspaceInfo getFirstWorkspace() {
return firstWorkspace;
}

@Exported
public String getDirectory() {
return directory;
}

@Exported
@SuppressWarnings("unused")
public boolean isPollOnController() {
return pollOnController;
}

// endregion

// region Overridden from parent class

/**
* {@inheritDoc}
*/
@Override
@Nonnull
public String getKey() {
StringBuilder builder = new StringBuilder("Plastic SCM");
for (WorkspaceInfo workspace : getAllWorkspaces()) {
builder.append(" ");
builder.append(Util.fixNull(workspace.getSelector()).replaceAll("\\s+", " "));
}
return builder.toString();
}

@Override
@CheckForNull
public RepositoryBrowser<?> guessBrowser() {
return null;
}

/**
* {@inheritDoc}
*/
@Override
public ChangeLogParser createChangeLogParser() {
return new ChangeSetReader();
}

/**
* {@inheritDoc}
*/
@Override
public void checkout(
@Nonnull final Run<?, ?> run,
@Nonnull final Launcher launcher,
@Nonnull final FilePath workspace,
@Nonnull final TaskListener listener,
@CheckForNull final File changelogFile,
@CheckForNull final SCMRevisionState baseline) throws IOException, InterruptedException {

Node node = BuildNode.getFromWorkspacePath(workspace);
adjustFieldsIfUsingOldConfigFormat();

List<ChangeSet> changeLogItems = new ArrayList<>();

ParametersAction parameters = run.getAction(ParametersAction.class);
List<ParameterValue> parameterValues = (parameters == null)
? Collections.emptyList()
: parameters.getParameters();

EnvVars environment = run.getEnvironment(listener);

for (WorkspaceInfo workspaceInfo : getAllWorkspaces()) {

FilePath plasticWorkspacePath = resolveWorkspacePath(workspace, workspaceInfo);
String resolvedSelector = SelectorParametersResolver.resolve(
workspaceInfo.getSelector(), parameterValues, environment);

if (!plasticWorkspacePath.exists()) {
plasticWorkspacePath.mkdirs();
}

PlasticTool tool = new PlasticTool(
CmTool.get(node, run.getEnvironment(listener), listener),
launcher,
listener,
plasticWorkspacePath,
buildClientConfigurationArguments(run.getParent(), resolvedSelector));

Workspace plasticWorkspace = WorkspaceManager.prepare(
tool, listener, plasticWorkspacePath, workspaceInfo.getCleanup());

WorkspaceManager.setSelector(tool, plasticWorkspace.getPath(), resolvedSelector);

ChangeSet cset = ChangesetDetails.forWorkspace(tool, plasticWorkspacePath, listener);

ChangeSet previousCset = retrieveLastBuiltChangeset(tool, run, plasticWorkspacePath, cset);
changeLogItems.addAll(retrieveMultipleChangesetDetails(
tool, plasticWorkspacePath, listener, previousCset, cset));

BuildData buildData = new BuildData(plasticWorkspace, cset);
List<BuildData> actions = run.getActions(BuildData.class);
if (!actions.isEmpty()) {
buildData.setIndex(actions.size() + 1);
}
run.addAction(buildData);
}

if (changelogFile != null) {
writeChangeLog(listener, changelogFile, changeLogItems);
}
}

/**
* Jenkins older than 2.60
* {@inheritDoc}
*
*/
@Override
public void buildEnvVars(@Nonnull AbstractBuild<?, ?> build, @Nonnull Map<String, String> env) {
super.buildEnvVars(build, env);
buildEnvironment(build, env);
}

/**
* Jenkins 2.60 and newer
* {@inheritDoc}
*/
@Override
public void buildEnvironment(@Nonnull Run<?, ?> build, @Nonnull Map<String, String> env) {
int index = 1;
for (BuildData buildData : build.getActions(BuildData.class)) {
ChangeSet cset = buildData.getChangeset();
if (cset != null) {
populateEnvironmentVariables(cset, env, PLASTIC_ENV_PREFIX);
if (additionalWorkspaces != null) {
populateEnvironmentVariables(cset, env, PLASTIC_ENV_PREFIX + index + "_");
index++;
}
} else {
LOGGER.warning("Unable to populate environment variables");
}
}
}

/**
* {@inheritDoc}
*/
@Override
public SCMRevisionState calcRevisionsFromBuild(
@Nonnull final Run<?, ?> run,
@Nullable final FilePath wkPath,
@Nullable final Launcher launcher,
@Nonnull final TaskListener listener) {
return SCMRevisionState.NONE;
}

/**
* {@inheritDoc}
*/
@Override
public PollingResult compareRemoteRevisionWith(
@Nonnull final Job<?, ?> project,
@Nullable final Launcher launcher,
@Nullable final FilePath workspace,
@Nonnull final TaskListener listener,
@Nonnull final SCMRevisionState baseline) throws IOException, InterruptedException {
if (project.getLastBuild() == null) {
listener.getLogger().println("No builds detected yet!");
return BUILD_NOW;
}

List<ParameterValue> parameters = getDefaultParameterValues(project);
Run<?, ?> lastBuild = project.getLastBuild();

EnvVars environment = lastBuild.getEnvironment(listener);

for (WorkspaceInfo workspaceInfo : getAllWorkspaces()) {
FilePath plasticWorkspacePath = resolveWorkspacePath(workspace, workspaceInfo);
String resolvedSelector = SelectorParametersResolver.resolve(
workspaceInfo.getSelector(), parameters, environment);

boolean hasChanges = hasChanges(
project,
launcher,
plasticWorkspacePath,
listener,
lastBuild.getTimestamp(),
resolvedSelector);

if (hasChanges) {
return BUILD_NOW;
}
}
return NO_CHANGES;
}

@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
}

@Nonnull
public ClientConfigurationArguments buildClientConfigurationArguments(
@Nullable Item item, @CheckForNull String selector) {
return new ClientConfigurationArguments(
workingMode,
CredentialsFinder.getFromId(credentialsId, item),
getServerFromSelector(selector));
}

@Override
public boolean requiresWorkspaceForPolling() {
return !pollOnController;
}

// endregion

// region Public methods

public List<WorkspaceInfo> getAllWorkspaces() {
List<WorkspaceInfo> result = new ArrayList<>();
result.add(firstWorkspace);
if (additionalWorkspaces != null) {
result.addAll(additionalWorkspaces);
}
return result;
}

// endregion

// region Private methods

/**
* Backward compatibility for jobs using old configuration format.
*/
private void adjustFieldsIfUsingOldConfigFormat() {
if (cleanup == null) {
LOGGER.warning("Missing 'cleanup' field. Update job configuration.");
cleanup = CleanupMethod.convertUseUpdate(useUpdate);
}
}

private static FilePath resolveWorkspacePath(
FilePath jenkinsWorkspacePath,
WorkspaceInfo workspaceInfo) {
if (jenkinsWorkspacePath == null || workspaceInfo == null) {
return null;
}
String subdirectory = workspaceInfo.getDirectory();
if (Util.fixEmpty(subdirectory) == null) {
return jenkinsWorkspacePath;
}
return new FilePath(jenkinsWorkspacePath, workspaceInfo.getDirectory());
}

/**
* Finds changeset of the last completed build for the same branch as the given changeset.
* Returns null if not found or is newer than the current build.
*/
private static ChangeSet retrieveLastBuiltChangeset(
PlasticTool tool, Run<?, ?> build, FilePath workspacePath, ChangeSet cset) {
if (cset == null
|| cset.getType() == ObjectSpecType.Shelve
|| Util.fixEmpty(cset.getBranch()) == null
|| Util.fixEmpty(cset.getRepoName()) == null
|| Util.fixEmpty(cset.getRepoServer()) == null) {
return null;
}

while (build != null) {
for (BuildData buildData : build.getActions(BuildData.class)) {
ChangeSet oldCset = buildData.getChangeset();
if (oldCset == null) {
continue;
}

if (!cset.getBranch().equals(oldCset.getBranch()) ||
!cset.getRepoName().equals(oldCset.getRepoName()) ||
!cset.getRepoServer().equals(oldCset.getRepoServer())) {
continue;
}

int oldCsetId = oldCset.getId();
if (oldCsetId <= 0 || oldCsetId >= cset.getId()) {
return null;
}

if (isExistingChangeset(tool, workspacePath, oldCset)) {
return oldCset;
}
}
build = build.getPreviousCompletedBuild();
}
return null;
}

private static boolean isExistingChangeset(PlasticTool tool, FilePath workspacePath, ChangeSet cset) {
FilePath xmlOutputPath = null;
try {
xmlOutputPath = OutputTempFile.getPathForXml(workspacePath);
ParseableCommand<ChangeSet> command = new FindChangesetCommand(cset.getObjectSpec(), xmlOutputPath);
return CommandRunner.executeAndRead(tool, command) != null;
} catch (Exception e) {
LOGGER.log(
Level.WARNING,
String.format(
"Unable to determine whether cset cs:%d@%s@%s exists: %s",
cset.getId(),
cset.getBranch(),
cset.getRepository(),
e.getMessage()),
e);
return false;
} finally {
if (xmlOutputPath != null) {
OutputTempFile.safeDelete(xmlOutputPath);
}
}
}

private static List<ChangeSet> retrieveMultipleChangesetDetails(
@Nonnull final PlasticTool tool,
@Nonnull final FilePath workspacePath,
@Nonnull final TaskListener listener,
@CheckForNull final ChangeSet fromCset,
@Nonnull final ChangeSet toCset) throws IOException, InterruptedException {

if (fromCset == null) {
return new ArrayList<ChangeSet>() {{ add(toCset); }};
return new ArrayList<>() {{ add(toCset); }};
}

FilePath xmlOutputPath = OutputTempFile.getPathForXml(workspacePath);
try {
ParseableCommand<List<ChangeSet>> command = new ChangesetRangeLogCommand(fromCset, toCset, xmlOutputPath);
List<ChangeSet> csets = CommandRunner.executeAndRead(tool, command, false);
for (ChangeSet cset : csets) {
cset.setRepoName(toCset.getRepoName());
cset.setRepoServer(toCset.getRepoServer());
}
return csets;
} catch (ParseException e) {
throw AbortExceptionBuilder.build(LOGGER, listener, e);
} finally {
OutputTempFile.safeDelete(xmlOutputPath);
}
}

private void writeChangeLog(
TaskListener listener,
File changelogFile,
List<ChangeSet> result) throws AbortException {
try {
ChangeSetWriter.write(result, changelogFile);
} catch (Exception e) {
throw AbortExceptionBuilder.build(LOGGER, listener, e);
}
}

private boolean hasChanges(
@Nullable Item item,
@CheckForNull Launcher launcher,
@CheckForNull FilePath workspacePath,
@Nonnull TaskListener listener,
@Nonnull Calendar lastCompletedBuildTimestamp,
@CheckForNull String selector) throws IOException, InterruptedException {

// hasChanges() can be invoked on the master, without any workspace
// We will provide the plugin with a LocalLauncher and a fake workspace, since:
// - PlasticTool needs a launcher and a workspace
// - getChanges() needs a place to put the temp file where it captures PlasticTool's output
if (launcher == null) {
launcher = new Launcher.LocalLauncher(listener);
}

if (workspacePath == null) {
workspacePath = new FilePath(new FilePath(Jenkins.getInstance().getRootDir()), CONTROLLER_WORKSPACE_FOLDER);
workspacePath = new FilePath(new FilePath(Jenkins.get().getRootDir()), CONTROLLER_WORKSPACE_FOLDER);
workspacePath.mkdirs();
}

String repSpec = getRepSpecFromSelector(selector);

PlasticTool plasticTool = new PlasticTool(
CmTool.get(BuildNode.getFromWorkspacePath(workspacePath), new EnvVars(EnvVars.masterEnvVars), listener),
launcher,
listener,
workspacePath,
buildClientConfigurationArguments(item, selector));
try {
List<ChangeSet> changesetsFromBuild = ChangesetsRetriever.getChangesets(
plasticTool,
workspacePath,
getBranchFromSelector(selector),
repSpec,
lastCompletedBuildTimestamp,
Calendar.getInstance());
return changesetsFromBuild.size() > 0;
return !changesetsFromBuild.isEmpty();
} catch (Exception e) {
e.printStackTrace(listener.error(String.format(
"%s: Unable to retrieve workspace status.", workspacePath.getRemote())));
return false;
}
}

private static List<ParameterValue> getDefaultParameterValues(Job<?, ?> project) {
ParametersDefinitionProperty paramDefProp = project.getProperty(ParametersDefinitionProperty.class);
if (paramDefProp == null) {
return null;
}

ArrayList<ParameterValue> result = new ArrayList<>();
for (ParameterDefinition paramDefinition : paramDefProp.getParameterDefinitions()) {
ParameterValue defaultValue = paramDefinition.getDefaultParameterValue();

if (defaultValue != null) {
result.add(defaultValue);
}
}
return result;
}

@CheckForNull
private static String getBranchFromSelector(@CheckForNull String selector) {
if (selector == null) {
return null;
}

Matcher smartbranchMatcher = BRANCH_PATTERN.matcher(selector);
if (smartbranchMatcher.matches()) {
return smartbranchMatcher.group(3);
}
return null;
}

@CheckForNull
private static String getRepSpecFromSelector(@CheckForNull String selector) {
if (selector == null) {
return null;
}

Matcher matcher = REPOSITORY_PATTERN.matcher(selector);
if (matcher.matches()) {
return matcher.group(2);
}
return null;
}

@CheckForNull
private static String getServerFromSelector(@CheckForNull String selector) {
return getServerFromRepositorySpec(getRepSpecFromSelector(selector));
}

@CheckForNull
private static String getServerFromRepositorySpec(@CheckForNull String repSpec) {
String repository = Util.fixEmpty(repSpec);

if (repository == null) {
return null;
}

int atSignIndex = repository.indexOf('@');
if (atSignIndex == -1) {
return null;
}

return repository.substring(atSignIndex + 1);

}

private void populateEnvironmentVariables(
@Nonnull final ChangeSet cset,
@Nonnull final Map<String, String> environment,
@CheckForNull final String prefix) {
environment.put(prefix + CHANGESET_ID, cset.getVersion());
environment.put(prefix + CHANGESET_GUID, cset.getGuid());
environment.put(prefix + BRANCH, cset.getBranch());
environment.put(prefix + AUTHOR, cset.getUser());
environment.put(prefix + REPSPEC, cset.getRepository());
}

// endregion

@SuppressWarnings("unused")
@Extension
public static class DescriptorImpl extends SCMDescriptor<PlasticSCM> {
public DescriptorImpl() {
super(PlasticSCM.class, null);
load();
}

@Override
@Nonnull
public String getDisplayName() {
return "Plastic SCM";
}

@SuppressWarnings("lgtm[jenkins/no-permission-check]")
@RequirePOST
@POST
public static FormValidation doCheckSelector(@QueryParameter String value) {
return FormChecker.doCheckSelector(value);
}

@RequirePOST
@POST
public static FormValidation doCheckDirectory(
@QueryParameter String value,
@QueryParameter boolean useMultipleWorkspaces,
@AncestorInPath Item item) {
if (Util.fixEmpty(value) == null && !useMultipleWorkspaces) {
return FormValidation.ok();
}
return FormChecker.doCheckDirectory(value, item);
}

public static String getDefaultSelector() {
return SelectorTemplates.DEFAULT;
}

@POST
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
return FormFiller.doFillCredentialsIdItems(item, credentialsId);
}

@RequirePOST
@POST
public FormValidation doCheckCredentialsId(
@AncestorInPath Item item,
@QueryParameter String value,
@QueryParameter String selector,
@QueryParameter WorkingMode workingMode
) throws IOException, InterruptedException {
return FormChecker.doCheckCredentialsId(
item,
value,
getServerFromSelector(selector),
workingMode);
}

@Override
public boolean isApplicable(Job project) {
return true;
}
}

@ExportedBean
public static final class WorkspaceInfo extends AbstractDescribableImpl<WorkspaceInfo> implements Serializable {
private static final long serialVersionUID = 1L;

private final String selector;

private final CleanupMethod cleanup;
@Deprecated
private transient boolean useUpdate;

private final String directory;

@DataBoundConstructor
public WorkspaceInfo(String selector, CleanupMethod cleanup, String directory) {
this.selector = selector;
this.cleanup = cleanup;
this.directory = directory;
}

@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
}

@Exported
public String getSelector() {
return selector;
}

@Exported
public CleanupMethod getCleanup() {
// Field might be null if deserialized from older class version.
return (cleanup != null) ? cleanup : CleanupMethod.convertUseUpdate(useUpdate);
return cleanup;

Check warning on line 730 in src/main/java/com/codicesoftware/plugins/hudson/PlasticSCM.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 159-730 are not covered by tests
}

@Exported
public String getDirectory() {
return directory;
}

@SuppressWarnings("unused")
@Extension
public static class DescriptorImpl extends Descriptor<WorkspaceInfo> {

@SuppressWarnings("lgtm[jenkins/no-permission-check]")
@RequirePOST
@POST
public static FormValidation doCheckSelector(@QueryParameter String value) {
return FormChecker.doCheckSelector(value);
}

@RequirePOST
@POST
public static FormValidation doCheckDirectory(@QueryParameter String value, @AncestorInPath Item item) {
return FormChecker.doCheckDirectory(value, item);
}
Expand All @@ -790,17 +761,4 @@
}
}
}

private static class GetCurrentNode extends MasterToSlaveCallable<String, InterruptedException> {
private static final long serialVersionUID = 1L;

@Override
public String call() {
Node node = Computer.currentComputer().getNode();
if (node == null) {
return null;
}
return node.getNodeName();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.verb.POST;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.logging.Logger;

@SuppressWarnings("unused")
public class PlasticSCMStep extends SCMStep {

private static final Logger LOGGER = Logger.getLogger(PlasticSCMStep.class.getName());
Expand All @@ -36,8 +37,6 @@ public class PlasticSCMStep extends SCMStep {
private WorkingMode workingMode = WorkingMode.NONE;
private String credentialsId = null;
private CleanupMethod cleanup = CleanupMethod.STANDARD;
@Deprecated
private transient boolean useUpdate;

private String directory = "";

Expand Down Expand Up @@ -126,12 +125,6 @@ public void setCleanup(CleanupMethod cleanup) {
this.cleanup = cleanup;
}

@Deprecated
public void setUseUpdate(boolean useUpdate) {
LOGGER.warning("Using deprecated 'useUpdate' field. Update job configuration.");
this.cleanup = CleanupMethod.convertUseUpdate(useUpdate);
}

public String getDirectory() {
return directory;
}
Expand Down Expand Up @@ -160,6 +153,7 @@ private String buildSelector() {
}
}

@SuppressWarnings("unused")
@Extension
public static final class DescriptorImpl extends SCMStepDescriptor {
public static final String defaultBranch = PlasticSCM.DEFAULT_BRANCH;
Expand All @@ -176,36 +170,37 @@ public String getDisplayName() {
}

@SuppressWarnings("lgtm[jenkins/no-permission-check]")
@RequirePOST
@POST
public FormValidation doCheckBranch(@QueryParameter String value) {
return FormChecker.doCheckBranch(value);
}

@SuppressWarnings("lgtm[jenkins/no-permission-check]")
@RequirePOST
@POST
public FormValidation doCheckRepository(@QueryParameter String value) {
return FormChecker.doCheckRepository(value);
}

@SuppressWarnings("lgtm[jenkins/no-permission-check]")
@RequirePOST
@POST
public FormValidation doCheckServer(@QueryParameter String value) {
return FormChecker.doCheckServer(value);
}

@RequirePOST
@POST
public static FormValidation doCheckDirectory(@QueryParameter String value, @AncestorInPath Item item) {
if (Util.fixEmpty(value) == null) {
return FormValidation.ok();
}
return FormChecker.doCheckDirectory(value, item);
}

@POST
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
return FormFiller.doFillCredentialsIdItems(item, credentialsId);
}

@RequirePOST
@POST
public FormValidation doCheckCredentialsId(
@AncestorInPath Item item,
@QueryParameter String value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ protected static boolean isNestedWorkspacePath(@Nonnull final String basePath, @
return fixedNestedPath.startsWith(fixedBasePath);
}

private interface WorkspacePathMatcher {
protected interface WorkspacePathMatcher {
boolean matches(String testPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -45,11 +44,11 @@ public MaskedArgumentListBuilder getArguments() {

@Override
@Nonnull
public List<ChangeSet.Item> parse(@Nonnull final Reader r) throws ParseException, IOException {
public List<ChangeSet.Item> parse(@Nonnull final Reader r) throws IOException {
ArrayList<ChangeSet.Item> result = new ArrayList<>();

BufferedReader reader = new BufferedReader(r);
String line = null;
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher = linePattern.matcher(line);
if (!matcher.matches()) {
Expand Down
Loading