-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcmd-install.go
56 lines (45 loc) · 1.12 KB
/
cmd-install.go
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
48
49
50
51
52
53
54
55
56
package main
import (
"os"
core "jplugins/coremgt"
"github.com/alecthomas/kingpin"
"github.com/forj-oss/forjj-modules/trace"
git "github.com/forj-oss/go-git"
)
type cmdInstall struct {
cmd *kingpin.CmdClause
lockFile *string
featureRepoPath *string
featureRepoURL *string
jenkinsHomePath *string
}
func (c *cmdInstall) doInstall() {
App.repository = core.NewRepository()
repo := App.repository
if !repo.LoadFromURL() {
os.Exit(1)
}
var elements *core.ElementsType
// Load the lock file in App.installedPlugins
if e, err := App.readFromSimpleFormat("", *c.lockFile) ; err != nil {
gotrace.Error("%s", err)
os.Exit(1)
} else {
elements = e
}
var savedBranch string
git.RunInPath(*c.featureRepoPath, func() error {
git.Do("stash")
savedBranch = git.GetCurrentBranch()
return nil
})
defer git.RunInPath(*c.featureRepoPath, func() error {
git.Do("checkout", savedBranch)
return nil
})
jenkinsHome := core.NewJenkinsHome(*c.jenkinsHomePath)
if err := jenkinsHome.Install(elements, *c.featureRepoPath) ; err != nil {
gotrace.Error("%s. Process aborted.", err)
os.Exit(1)
}
}