Allow for using Circle CI tooling without a TTY

cli

#1

When trying to automate some of the provided tasks by the Circle CI CLI (https://circleci.com/docs/2.0/local-jobs/#installing-the-cli-locally) using another build tool, they will fail with the following message:

the input device is not a TTY

It would be awesome if the CLI would allow itself to be executed without a TTY so it can be used in other automated tooling.


#2

You can’t pipe the local CLI tool since it’s a Docker image.


#3

I am fairly confident you can pipe Docker STDOUT and STDERR the same way as other CLI tools. I didn’t realize the local CLI was just a shell script around some Docker execution.

Looking at it though, the -t should just be removed from the docker run -it --rm command to work in non TTY.


#4

Thanks for pointing that out, this worked!

I agree, pretty obviously, you can pipe stdout and stderr :slight_smile:

Would love to see this officially supported without having to manually tweak the circleci script.

This is e.g. necessary to integrate this with pre-commit, which looks something like this:

-   id: validate-circleci-config
    name: Validating CircleCI config.yml
    language: system
    entry: circleci config validate -c .circleci/config.yml
    files: ^\.circleci/config\.yml$

but with the -t flag results in:

Validating CircleCI config.yml.................................Failed
hookid: validate-circleci-config

the input device is not a TTY

#5

Same issue here.

We’re validating changes in .circleci/config.yml using a pre-commit hook:

#!/bin/sh


# Redirect output to stderr.
exec 1>&2

ROOT_DIR=`git rev-parse --show-toplevel`

# validate CircleCI config.yml if it contains uncommitted changes
CIRCLECI_CONFIG_FILE=".circleci/config.yml"
if [ `git diff --name-only | grep $CIRCLECI_CONFIG_FILE` ] ; then
        echo -n "Validating CircleCI config file at ${CIRCLECI_CONFIG_FILE}"
        circleci config validate ${ROOT_DIR}/${CIRCLECI_CONFIG_FILE} || exit 1
fi

which results in “the input device is not a TTY”

Our workaround is to add exec < /dev/tty to the script.

see: https://circleci.com/blog/circleci-hacks-validate-circleci-config-on-every-commit-with-a-git-hook/


#6

[Reprise] Allow for using Circle CI tooling without a TTY