[JIRA] (JENKINS-60242) tty is not allocated for `sh` step in `docker` agent

7 views
Skip to first unread message

bartosz.rempuszewski@gmail.com (JIRA)

unread,
Nov 21, 2019, 8:01:03 AM11/21/19
to jenkinsc...@googlegroups.com
Bartosz Rempuszewski created an issue
 
Jenkins / Bug JENKINS-60242
tty is not allocated for `sh` step in `docker` agent
Issue Type: Bug Bug
Assignee: Unassigned
Components: jenkinsfile-runner
Created: 2019-11-21 13:00
Priority: Minor Minor
Reporter: Bartosz Rempuszewski

 

With test pipeline:

pipeline {
    stages {
        stage('test  tty') {
            agent { docker { image 'alpine'; alwaysPull true; reuseNode true } }
            steps {
                sh "tty"
            }
        }
    }
}

 

 

I can see in logs:

 

docker run -t -d [ ... other options ... ] cat

so the container is started with tty

 

but output from `sh` command is:

+ tty
not a tty

It looks like shell command is executed with `docker exec somename somecommand` instead of `docker exec -t somename somecommand`

Is there a way to start `sh` step with tty enabled?

 

Note: in case of some commands it is important to run with `tty`, for example https://mustache.github.io/mustache.1.html

`mustache --error params template` will fail with error.

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

bartosz.rempuszewski@gmail.com (JIRA)

unread,
Nov 21, 2019, 8:02:02 AM11/21/19
to jenkinsc...@googlegroups.com
Bartosz Rempuszewski updated an issue
Change By: Bartosz Rempuszewski
 

With test pipeline:
{code:java}
pipeline {
    agent { docker { image 'alpine' } }
    stages {
        stage('test  tty') {
            agent { docker { image 'alpine'; alwaysPull true; reuseNode true } }
            steps {
                sh "tty"
            }
        }
    }
}
{code}

 

 

I can see in logs:

 
{code:java}

docker run -t -d [ ... other options ... ] cat
{code}

so the container is started with tty

 

but output from `sh` command is:
{code:java}

+ tty
not a tty
{code}

It looks like shell command is executed with `docker exec somename somecommand` instead of `docker exec -t somename somecommand`

Is there a way to start `sh` step with tty enabled?

 

Note: in case of some commands it is important to run with `tty`, for example [https://mustache.github.io/mustache.1.html]

`mustache --error params template` will fail with error.

 

 

bartosz.rempuszewski@gmail.com (JIRA)

unread,
Nov 21, 2019, 8:05:03 AM11/21/19
to jenkinsc...@googlegroups.com
Bartosz Rempuszewski updated an issue
 

With test pipeline:
{code:java}
pipeline {
    agent { docker { image 'alpine' } }
    stages {
        stage('test  tty') {
            steps {
                sh "tty"
            }
        }
    }
}
{code}
 

 

I can see in logs:

 
{code:java}
docker run -t -d [ ... other options ... ] cat
{code}
so the container is started with tty

 

but output from `sh` command is:
{code:java}
+ tty
not a tty
{code}
It looks like shell command is executed with `docker exec somename somecommand` instead of `docker exec -t somename somecommand`

Is there a way to start `sh` step with tty enabled?

 

Note: in case of some commands it is important to run with `tty`, for example [https://mustache.github.io/mustache.1.html]

`mustache --error params template` will fail with error.

 

I am not sure if JENKINS-39013 is related - in my case container is run with tty but 'sh' step inside the container are not.

 

 

o.v.nenashev@gmail.com (JIRA)

unread,
Apr 21, 2020, 5:00:03 AM4/21/20
to jenkinsc...@googlegroups.com
Oleg Nenashev updated an issue
Change By: Oleg Nenashev
Component/s: pipeline
Component/s: jenkinsfile-runner
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages