-
Notifications
You must be signed in to change notification settings - Fork 1
/
oJobGIT.yaml
47 lines (41 loc) · 1.83 KB
/
oJobGIT.yaml
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
46
47
# GIT oJob functionality
# Copyright 2023 Nuno Aguiar
jobs:
- name: GIT Copy Repository
help: >
Will copy a GIT repository files. Expects:
- gittarget (String) The GIT repository files copy target folder.
- giturl (String) The GIT repository url.
- gittemp (String) The temporary folder to clone the GIT repository (defaults to gittarget + ".tmp").
- gitbranch (String) The specific branch to checkout (defaults to master).
- gituser (String) The GIT remote repository user (can be encrypted).
- gitpass (String) The GIT remote repository pass (can be encrypted).
exec: |
var target = _$(args.gittarget).$_("You need to specify a git target folder (gittarget)");
var giturl = _$(args.giturl).$_("You need to provide a giturl");
var temp = _$(args.gittemp).default(target + ".tmp");
var gitbranch = _$(args.gitbranch).default(void 0);
var gituser = _$(args.gituser).default(void 0);
var gitpass = _$(args.gitpass).default(void 0);
log("Checking temp and target folders...");
io.mkdir(target);
io.mkdir(temp);
if (io.fileExists(temp + "/.git")) {
logErr("The temp folder can't have an active GIT repository.");
throw "The temp folder can't have an active GIT repository.";
}
plugin("GIT");
try {
var git = new GIT();
log("Retriving '" + giturl + "' to '" + temp + "' temporary folder...");
git.clone(giturl, temp, false, gitbranch, gituser, gitpass);
log("Preparing target folder '" + target + "'...");
io.rm(target);
io.rm(temp + "/.git");
io.mv(temp, target);
log("Repository copy done.");
} catch(e) {
logErr("Problem copying repository: " + String(e));
} finally {
io.rm(temp);
}