2

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
Ade Firman Fauzi
  • 377
  • 3
  • 15

1 Answers1

2

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?

Stefan van Gastel
  • 4,330
  • 23
  • 25
  • Ah i see, anyway i have 2 input for example. Is that works when there any input again? For example, `npm run setup` has 2 trigger input, like username & password. So can i doing that with this method? `yes 'Gitlab CI' | npm run setup` yes `password` | npm run setup` I'm doing this for setup DB. I think it's a good idea using prompt for connecting to DB. – Ade Firman Fauzi Dec 13 '17 at 04:19