cli: Cannot authenticate in my CI/CD CircleCI workflow
I’m trying to integrate netlify deploys to my CI/CD workflow in CircleCI but I am running into authentication issues.
I’ve set up the NETLIFY_AUTH_TOKEN env variable in the circleci project and i’ve also tried connecting to the container via SSH and setting it manually via export NETLIFY_AUTH_TOKEN=XXXX.
I’ve also tried using netlify deploy --auth xxxx.
This all results in:
Logging into your Netlify account...
Opening https://app.netlify.com/authorize?response_type=ticket&ticket=xxxx
---------------------------
Error: Unable to open browser automatically
Please open your browser & open the URL below to login:
https://app.netlify.com/authorize?response_type=ticket&ticket=xxxx
---------------------------
Why is this happening?
My project does not have netlify config files. What I want to do is create a new site for every PR.
This is the workflow:
deploy-netlify-preview:
docker:
- image: circleci/node:10
steps:
- attach_workspace:
at: ~/
- run:
name: "Set site name"
command: site="EMPLOYERS-PR-${CIRCLE_PR_NUMBER}"
- run:
name: "Set Netlify Token env variable"
command: export NETLIFY_AUTH_TOKEN=${NETLIFY_AUTH_TOKEN}
- run:
name: "Install Netlify CLI tools"
command: sudo npm install -g netlify-cli
- run:
name: "Fetch sites from Netlify"
command: sites="$(netlify sites:list)"
- run:
name: "Create site if it doesn't exist"
command: |
if [[ ! "$sites" =~ "$site" ]]
then
netlify sites:create --name "$site" -a ${NETLIFY_TEAM_SLUG}
fi
- run:
name: "Deploy site"
command: netlify deploy --prod -s "$site" --dir build
It actually hangs at “Fetch sites from Netlify” (stuck loading without error);
When connecting to the container via SSH and trying to deploy manually, login message occurrs. If I printenv I can see NETLIFY_AUTH_TOKEN is set properly.
Env:
- Node: v10
- Docker image: circleci/node:10
- netlify-cli/2.11.23 linux-x64 node-v10.16.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (8 by maintainers)
Just released
netlify-cli/2.11.24Install that and give it a go. All commands should now respect
process.env.NETLIFY_AUTH_TOKEN