-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
45 lines (39 loc) · 1.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
const fs = require('fs');
const path = require('path');
const { BookendInterface } = require('screwdriver-build-bookend');
const ARTIFACTS_DIR_SUFFIX = 'ARTIFACTS';
const COMMANDS = fs.readFileSync(path.join(__dirname, 'commands.txt'), 'utf8').trim();
class ArtifactBookend extends BookendInterface {
/**
* Constructor for ArtifactBookend
* @method constructor
* @param {Object} config Configuration
* @return {ArtifactBookend}
*/
constructor(storeUrl) {
super();
this.storeUrl = storeUrl;
this.teardownCommands = COMMANDS.replace(/\\\\\$ARTIFACTS_DIR_SUFFIX/g, ARTIFACTS_DIR_SUFFIX)
.replace(/\\\\\$STORE_URL/g, storeUrl)
.split('\n');
}
/**
* Gives the commands needed for setting up Artifact Storage before the build starts.
* Currently, there is nothing to set up
* @method getSetupCommand
* @return {Promise} Resolves to an empty string
*/
getSetupCommand() {
return Promise.resolve('');
}
/**
* Gives the commands needed for storing artifacts after a build completes.
* @method getTeardownCommand
* @return {Promise} Resolves to a string that represents the commmand to execute
*/
getTeardownCommand() {
return Promise.resolve(this.teardownCommands.join(' && '));
}
}
module.exports = ArtifactBookend;