Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Miroslav Vadkerti
gitlab-runner
Commits
bd7d53c8
Commit
bd7d53c8
authored
Apr 22, 2015
by
Kamil Trzciński
🔴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PTY to shell
parent
9c8a7cc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
common/config.go
common/config.go
+5
-0
executors/shell/executor_shell.go
executors/shell/executor_shell.go
+23
-0
No files found.
common/config.go
View file @
bd7d53c8
...
...
@@ -48,6 +48,7 @@ type RunnerConfig struct {
Shell
string
`toml:"shell" json:"shell"`
DisableVerbose
bool
`toml:"disable_verbose" json:"disable_verbose"`
DisablePTY
*
bool
`toml:"disable_pty" json:"disable_pty"`
SSH
*
ssh
.
Config
`toml:"ssh" json:"ssh"`
Docker
*
DockerConfig
`toml:"docker" json:"docker"`
...
...
@@ -72,6 +73,10 @@ func (c *RunnerConfig) UniqueID() string {
return
c
.
URL
+
c
.
Token
}
func
(
c
*
RunnerConfig
)
IsPTYEnabled
()
bool
{
return
c
.
DisablePTY
==
nil
||
!*
c
.
DisablePTY
}
func
(
c
*
Config
)
LoadConfig
(
configFile
string
)
error
{
info
,
err
:=
os
.
Stat
(
configFile
)
if
err
!=
nil
{
...
...
executors/shell/executor_shell.go
View file @
bd7d53c8
...
...
@@ -8,15 +8,19 @@ import (
"os/exec"
"path/filepath"
krpty
"github.com/kr/pty"
"github.com/ayufan/gitlab-ci-multi-runner/common"
"github.com/ayufan/gitlab-ci-multi-runner/executors"
"github.com/ayufan/gitlab-ci-multi-runner/helpers"
"io"
)
type
ShellExecutor
struct
{
executors
.
AbstractExecutor
cmd
*
exec
.
Cmd
scriptDir
string
pty
*
os
.
File
}
func
(
s
*
ShellExecutor
)
Prepare
(
config
*
common
.
RunnerConfig
,
build
*
common
.
Build
)
error
{
...
...
@@ -51,6 +55,21 @@ func (s *ShellExecutor) Start() error {
s
.
cmd
.
Stdout
=
s
.
BuildLog
s
.
cmd
.
Stderr
=
s
.
BuildLog
// Open PTY if available
if
s
.
Config
.
IsPTYEnabled
()
{
pty
,
tty
,
err
:=
krpty
.
Open
()
if
err
==
nil
{
go
io
.
Copy
(
s
.
BuildLog
,
pty
)
defer
tty
.
Close
()
s
.
cmd
.
Stdout
=
tty
s
.
cmd
.
Stderr
=
tty
s
.
pty
=
pty
}
else
if
err
!=
krpty
.
ErrUnsupported
{
s
.
Errorln
(
"Failed to open pty"
,
err
)
}
}
// Save shell script as file
if
s
.
ShellScript
.
PassFile
{
scriptDir
,
err
:=
ioutil
.
TempDir
(
""
,
"build_script"
)
if
err
!=
nil
{
...
...
@@ -89,6 +108,10 @@ func (s *ShellExecutor) Cleanup() {
os
.
RemoveAll
(
s
.
scriptDir
)
}
if
s
.
pty
!=
nil
{
s
.
pty
.
Close
()
}
s
.
AbstractExecutor
.
Cleanup
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment