Commit 90ede17a authored by Kamil Trzciński's avatar Kamil Trzciński

Use absolute path for GitLab Runner

parent ee7a0010
Pipeline #280579 passed with stages
v 0.7.2
- Use absolute path when executing archive command
v 0.7.1
- Fix caching support
- Suppress tar verbose output
......
......@@ -50,10 +50,11 @@ func (s *ShellScript) String() string {
}
type ShellScriptInfo struct {
Shell string
Build *Build
Type ShellType
User *string
Shell string
Build *Build
Type ShellType
User *string
RunnerCommand string
}
type Shell interface {
......
......@@ -9,6 +9,7 @@ import (
"path/filepath"
"fmt"
"github.com/Sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/common"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/executors"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
......@@ -111,13 +112,20 @@ func (s *ShellExecutor) Cleanup() {
}
func init() {
// Look for self
runnerCommand, err := exec.LookPath(os.Args[0])
if err != nil {
logrus.Warningln(err)
}
options := executors.ExecutorOptions{
DefaultBuildsDir: "$PWD/builds",
DefaultCacheDir: "$PWD/cache",
SharedBuildsDir: true,
Shell: common.ShellScriptInfo{
Shell: common.GetDefaultShell(),
Type: common.LoginShell,
Shell: common.GetDefaultShell(),
Type: common.LoginShell,
RunnerCommand: runnerCommand,
},
ShowHostname: false,
}
......
......@@ -197,7 +197,7 @@ func (b *BashShell) generateCommands(info common.ShellScriptInfo) string {
return b.finalize(buffer.String())
}
func (b *BashShell) archiveFiles(w io.Writer, list interface{}, archiveType, archivePath string) {
func (b *BashShell) archiveFiles(w io.Writer, list interface{}, runnerCommand, archiveType, archivePath string) {
hash, ok := list.(map[string]interface{})
if !ok {
return
......@@ -231,7 +231,10 @@ func (b *BashShell) archiveFiles(w io.Writer, list interface{}, archiveType, arc
// Execute archive command
b.echoColoredFormat(w, "Archiving %s...", archiveType)
b.executeCommand(w, "gitlab-runner", args...)
if runnerCommand == "" {
runnerCommand = "gitlab-runner"
}
b.executeCommand(w, runnerCommand, args...)
}
func (b *BashShell) generatePostBuildScript(info common.ShellScriptInfo) string {
......@@ -243,11 +246,11 @@ func (b *BashShell) generatePostBuildScript(info common.ShellScriptInfo) string
// Find cached files and archive them
if cacheFile := info.Build.CacheFile(); cacheFile != "" {
b.archiveFiles(w, info.Build.Options["cache"], "cache", cacheFile)
b.archiveFiles(w, info.Build.Options["cache"], info.RunnerCommand, "cache", cacheFile)
}
// Find artifacts
b.archiveFiles(w, info.Build.Options["artifacts"], "artifacts", "artifacts.tgz")
b.archiveFiles(w, info.Build.Options["artifacts"], info.RunnerCommand, "artifacts", "artifacts.tgz")
// If archive is created upload it
b.writeIfFile(w, "artifacts.tgz")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment