This question been asked multiple times but most of them was easy to solve, although using tool expect
it doesn't work as I've expected:
/usr/bin/expect <<EOD
spawn npm adduser
expect {
"Username:" {send "$USERNAME\r"; exp_continue}
"Password:" {send "$PASSWORD\r"; exp_continue}
"Email: (this IS public)" {send "$EMAIL\r"; exp_continue}
}
EOD
There's also more simple variant for the same purpose:
npm adduser <<!
$NPM_USERNAME
$NPM_PASSWORD
$NPM_EMAIL
!
.gitlab-ci.yml: this way it will produce one line string which is not good and command won't work
npm_push:
dependencies:
- test
script:
- npm adduser <<!
$NPM_USERNAME
$NPM_PASSWORD
$NPM_EMAIL
!
- npm config set registry https://$NPM_URL
- npm push
How can I pass it in such way so that gitlab-runner execute this command in multi-line manner when passing it to bash?
Found it finally
npm_publish:
stage: deploy
only:
- master
script:
- apk update
- apk add expect git alpine-sdk python python-dev
- npm config set registry https://$NPM_URL
- npm install publish
- |
/usr/bin/expect <<EOD
spawn npm adduser
expect {
"Username:" {send "$NPM_USERNAME\r"; exp_continue}
"Password:" {send "$NPM_PASSWORD\r"; exp_continue}
"Email: (this IS public)" {send "$NPM_EMAIL\r"; exp_continue}
}
EOD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With