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

[FtpUploadV2] Fail on exception when reading FTP options #14742

Merged
merged 4 commits into from
Apr 20, 2021
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 @@ -36,6 +36,7 @@
"loc.messages.Disconnected": "disconnected",
"loc.messages.DisconnectHost": "disconnecting from: %s",
"loc.messages.FTPConnected": "connected: %s",
"loc.messages.InvalidFTPOptions": "There was an error when reading FTP options: %s",
"loc.messages.FTPNoHostSpecified": "The FTP server URL must include a host name",
"loc.messages.FTPNoProtocolSpecified": "The FTP server URL must begin with ftp:// or ftps://",
"loc.messages.NoFilesFound": "Could not find any files to upload",
Expand Down
8 changes: 7 additions & 1 deletion Tasks/FtpUploadV2/ftpuploadtask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ async function run() {
tl.setResourcePath(path.join(__dirname, "task.json"));

const tries = 3;
const ftpOptions: FtpOptions = getFtpOptions();
let ftpOptions: FtpOptions;
try {
ftpOptions = getFtpOptions();
} catch (err) {
tl.setResult(tl.TaskResult.Failed, tl.loc('InvalidFTPOptions', err));
return;
}

if (!ftpOptions.serverEndpointUrl.protocol) {
tl.setResult(tl.TaskResult.Failed, tl.loc("FTPNoProtocolSpecified"));
Expand Down
5 changes: 3 additions & 2 deletions Tasks/FtpUploadV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 2,
"Minor": 186,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.182.1",
"instanceNameFormat": "FTP Upload: $(rootFolder)",
Expand Down Expand Up @@ -195,6 +195,7 @@
"Disconnected": "disconnected",
"DisconnectHost": "disconnecting from: %s",
"FTPConnected": "connected: %s",
"InvalidFTPOptions": "There was an error when reading FTP options: %s",
"FTPNoHostSpecified": "The FTP server URL must include a host name",
"FTPNoProtocolSpecified": "The FTP server URL must begin with ftp:// or ftps://",
"NoFilesFound": "Could not find any files to upload",
Expand All @@ -203,4 +204,4 @@
"UploadSucceedRes": "FTP upload successful",
"UploadFailed": "Ftp Upload failed"
}
}
}
3 changes: 2 additions & 1 deletion Tasks/FtpUploadV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 2,
"Minor": 186,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.182.1",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -195,6 +195,7 @@
"Disconnected": "ms-resource:loc.messages.Disconnected",
"DisconnectHost": "ms-resource:loc.messages.DisconnectHost",
"FTPConnected": "ms-resource:loc.messages.FTPConnected",
"InvalidFTPOptions": "ms-resource:loc.messages.InvalidFTPOptions",
"FTPNoHostSpecified": "ms-resource:loc.messages.FTPNoHostSpecified",
"FTPNoProtocolSpecified": "ms-resource:loc.messages.FTPNoProtocolSpecified",
"NoFilesFound": "ms-resource:loc.messages.NoFilesFound",
Expand Down