I am running a bash script to build a docker container inside circleci execution. I want to enter the letters ‘y’ or ‘n’ to proceed further, how can i do that?
If you are working in bash it can be as simple as
echo "Y" | command
You may get quicker replies for general Linux questions if you use a site like StackExchange/StackOverflow. They have a more advanced ‘natural’ language search engine that can often find an answer from their database and a far larger community of users to provide a quicker reply. As these forums are focussed on just CircleCI tooling there are fewer people around who can reply.
yes i had seen this, but the issue is i am not able to enter into the bash of a container in circle ci.
I’m not sure what you mean.
If you are building a docker container you are likely to be using a Dockerfile that uses the ‘RUN’ command to execute bash commands to build the contents of the container. So changing the command so that a “Y” is provided can be done by changing the ‘RUN’ command.
So the main issue I am facing now is, even though adding the echo command before the bash command works locally and i get the output, but on circleci although it executes properly, there is no output. I wish i could upload an image for more clarity but being a new user i cannot do that.
the command I am using for simple testing to see if it works :
“echo ls | docker exec -i bash” . This command works perfectly fine locally and as output i get all the contents of the container, but on circleci i do not get any output. It just says :
#!/bin/bash -eo pipefail
echo ls | docker exec -i bash
CircleCI received exit code 0
Could you try providing the full job config?
As KyleTryon has already requested can you provide your circleci job.
In your example you are using docker exec, but that needs a container name
Below is a quick (and very simple) test job that I have created which executes a ‘docker run’ instead of exec and it does return an ls list, so your exact configuration will matter.
version: 2.1
executors:
hosted_node:
machine:
image: ubuntu-2004:current
resource_class: medium
jobs:
build:
executor: hosted_node
steps:
- run:
name: do an ls inside a container
command: |
echo ls | docker run -i bash
workflows:
build_and_test:
jobs:
- build
The canonical way to do this is to use the yes
program, as in yes | your_bash_script_here
. See man yes
for details.
But as other have mentioned here, it’s really hard to help you without more details.