Skip to content

Commit

Permalink
[JENKINS-74018] Migrate legacy checkUrl attributes in `BapSshTransf…
Browse files Browse the repository at this point in the history
…er/config.jelly` (#360)
  • Loading branch information
yaroslavafenkin authored Oct 29, 2024
1 parent 2f3cb2a commit d76ba0f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ public FormValidation doCheckExecTimeout(@QueryParameter final String value) {
return FormValidation.validateNonNegativeInteger(value);
}

public FormValidation doCheckSourceFiles(@QueryParameter final String configName, @QueryParameter final String sourceFiles,
public FormValidation doCheckSourceFiles(@QueryParameter final String sourceFilesConfigName, @QueryParameter final String value,
@QueryParameter final String execCommand) {
if (Util.fixEmptyAndTrim(configName) != null) {
if (Util.fixEmptyAndTrim(sourceFilesConfigName) != null) {
final BapSshPublisherPlugin.Descriptor pluginDescriptor = Jenkins.getActiveInstance().getDescriptorByType(
BapSshPublisherPlugin.Descriptor.class);
final BapSshHostConfiguration hostConfig = pluginDescriptor.getConfiguration(configName);
final BapSshHostConfiguration hostConfig = pluginDescriptor.getConfiguration(sourceFilesConfigName);
if (hostConfig == null)
return FormValidation.error(Messages.descriptor_sourceFiles_check_configNotFound(configName));
return FormValidation.error(Messages.descriptor_sourceFiles_check_configNotFound(sourceFilesConfigName));
if (hostConfig.isEffectiveDisableExec())
return FormValidation.validateRequired(sourceFiles);
return FormValidation.validateRequired(value);
}
return checkTransferSet(sourceFiles, execCommand);
return checkTransferSet(value, execCommand);
}

public FormValidation doCheckPatternSeparator(@QueryParameter final String value) {
return BPValidators.validateRegularExpression(value);
}

public FormValidation doCheckExecCommand(@QueryParameter final String sourceFiles, @QueryParameter final String execCommand) {
return checkTransferSet(sourceFiles, execCommand);
public FormValidation doCheckExecCommand(@QueryParameter final String sourceFiles, @QueryParameter final String value) {
return checkTransferSet(sourceFiles, value);

Check warning on line 75 in src/main/java/jenkins/plugins/publish_over_ssh/descriptor/BapSshTransferDescriptor.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 58-75 are not covered by tests
}

private FormValidation checkTransferSet(final String sourceFiles, final String execCommand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@

<poj:defaultMessages/>

<f:invisibleEntry>
<f:textbox clazz="ssh-transfer-source-files-config-name" field="sourceFilesConfigName"/>
</f:invisibleEntry>
<f:entry title="${m.sourceFiles()}" field="sourceFiles" help="${descriptor.getHelpFile((inPromotion and !matrixPromotion) ? 'sourceFilesForPromotion' : 'sourceFiles')}">
<f:textbox checkUrl="'${rootURL}/descriptorByName/jenkins.plugins.publish_over_ssh.BapSshTransfer/checkSourceFiles'+qs(this).nearBy('sourceFiles').nearBy('execCommand').toString()+bap_get_configName_qs(this)" default="${defaults.transfer.sourceFiles}"/>
<f:textbox default="${defaults.transfer.sourceFiles}"/>
</f:entry>

<f:entry title="${m.removePrefix()}" field="removePrefix">
Expand All @@ -41,7 +44,7 @@
</f:entry>

<f:entry title="${%execCommand}" field="execCommand">
<poj:textarea checkUrl="'${rootURL}/descriptorByName/jenkins.plugins.publish_over_ssh.BapSshTransfer/checkExecCommand'+qs(this).nearBy('sourceFiles').nearBy('execCommand').toString()" minRows="1" class="ssh-exec-control" default="${defaults.transfer.execCommand}"/>
<f:textarea class="ssh-exec-control" default="${defaults.transfer.execCommand}"/>
</f:entry>

<f:description>
Expand Down
14 changes: 13 additions & 1 deletion src/main/webapp/js/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,20 @@ var sshBehave = {
bap_show_exec_controls(publisher);
}
bap_blur_inputs(publisher);
updateSourceFilesConfigName(configName);
};
}
};

Behaviour.register(sshBehave);
Behaviour.register(sshBehave);

function updateSourceFilesConfigName(configNameElement) {
const parentContainer = configNameElement.closest("div[name='publishers']");
parentContainer.querySelectorAll(".ssh-transfer-source-files-config-name").forEach(function (hiddenField) {
hiddenField.value = configNameElement.value;
});
}

Behaviour.specify(".ssh-transfer-source-files-config-name", "SshTransfer_syncSourceFileConfigName", 0, function (element) {
element.value = element.closest("div[name='publishers']").querySelector("select.ssh-config-name").value;
});

0 comments on commit d76ba0f

Please sign in to comment.