Skip to content

Commit

Permalink
Fix move artifact files issue on linux. (#6927)
Browse files Browse the repository at this point in the history
Fix move artifact files issue on linux.
  • Loading branch information
omeshp authored Apr 10, 2018
1 parent 3e29d1c commit 8b4bbf6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
21 changes: 18 additions & 3 deletions Tasks/JenkinsDownloadArtifacts/jenkinsdownloadartifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { JenkinsRestClient, JenkinsJobDetails } from "./ArtifactDetails/JenkinsR
var DecompressZip = require('decompress-zip');
var fsExtra = require('fs-extra');
var taskJson = require('./task.json');
var uuidv4 = require('uuid/v4');

const area: string = 'JenkinsDownloadArtifacts';

Expand Down Expand Up @@ -171,9 +172,23 @@ async function doWork() {
tl.rmRF(zipLocation);
}

fsExtra.move(path.join(localPathRoot, "archive"), localPathRoot).catch((error) => {
throw error;
});
var archivePath = path.join(localPathRoot, "archive");
var tempPath = path.join(localPathRoot, uuidv4());
fsExtra.move(archivePath, tempPath)
.then(() => {
fsExtra.copy(tempPath, localPathRoot)
.then(() => {
fsExtra.remove(tempPath).catch((error) => {
throw error;
});
})
.catch((error) => {
throw error;
});
})
.catch((error) => {
throw error;
});
}
else {
await getArtifactsFromUrl(artifactQueryUrl, strictSSL, localPathRoot, itemPattern, handler, variables);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/JenkinsDownloadArtifacts/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 133,
"Patch": 1
"Patch": 2
},
"groups": [
{
Expand Down
2 changes: 1 addition & 1 deletion Tasks/JenkinsDownloadArtifacts/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 133,
"Patch": 1
"Patch": 2
},
"groups": [
{
Expand Down

0 comments on commit 8b4bbf6

Please sign in to comment.