Trigger input on Gitlab Ci

2.2k Views Asked by At

I'm so curious about trigger input on gitlab CI pipeline *cmiiw. So, the main problem when there's any prompt on Node.js like this,

Ubuntu

enter image description here

But when i'm trying to implementation into Gitlab CI, there's any error something like this

Gitlab.CI

enter image description here

This is my gitlab.ci.yml script

image: node:latest

cache:
  paths:
  - node_modules/

all_tests:
  script:
   - npm install
   - npm run setup
   - John Doe \n
   - npm run test
1

There are 1 best solutions below

1
On

First, CI best-practices suggest you create a --force or --no-interactive variant of your installer, to omit interactive input in case of automated deploys.

A workaround could be to use the yes unix util. This util lets you feed a string to interactive input like this (in your case):

image: node:latest

cache:
  paths:
  - node_modules/

all_tests:
  script:
   - npm install
   - yes 'Gitlab CI' | npm run setup
   - npm run test

This will answer 'Gitlab CI' to all questions asked so its rather limited.

Btw; I think you mean .gitlab-ci.yml instead of travis.ci.yml in your question?