Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secrets are randomly / or on pull request not set. #2605

Closed
Pfeifenjoy opened this issue Feb 22, 2019 · 1 comment
Closed

Secrets are randomly / or on pull request not set. #2605

Pfeifenjoy opened this issue Feb 22, 2019 · 1 comment

Comments

@Pfeifenjoy
Copy link

Hey,

I am experiencing random failures in my build because a secret is not set as an environment variable.
My setup is as follows:
I have a drone server on a low power machine, which should build my node projects
and then publish them to NPM.
The projects are hosted in a private gitea server, and the drone server waits for events from this.

The .core.yml looks as follows:

kind: pipeline
name: default

steps:

- name: install
  image: node
  environment:
    NPM_TOKEN:
      from_secret: npm_token
  commands:
  - npm install

- name: test
  image: node
  environment:
    NPM_TOKEN:
      from_secret: npm_token
  commands:
  - npm test

- name: build
  image: node
  environment:
    NPM_TOKEN:
      from_secret: npm_token
  commands:
  - npm run build

- name: publish
  image: node
  environment:
    NPM_TOKEN:
      from_secret: npm_token
  commands:
    - if [ "$(npm view @arwed/sanitize dist-tags.latest)" = "$(node -p -e "require('./package.json').version")" ]; then echo not publishing; else npm whoami & npm publish; fi
  when:
    branch:
    - master
    event:
      exclude:
      - pull_request

In the install step I get:

+ npm install
--
2 | Error: Failed to replace env in config: ${NPM_TOKEN}
3 | at /usr/local/lib/node_modules/npm/lib/config/core.js:415:13
4 | at String.replace (<anonymous>)
5 | at envReplace (/usr/local/lib/node_modules/npm/lib/config/core.js:411:12)
6 | at parseField (/usr/local/lib/node_modules/npm/lib/config/core.js:389:7)
7 | at /usr/local/lib/node_modules/npm/lib/config/core.js:330:24
8 | at Array.forEach (<anonymous>)
9 | at Conf.add (/usr/local/lib/node_modules/npm/lib/config/core.js:328:23)
10 | at ConfigChain.addString (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
11 | at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:316:10)
12 | at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:16
13 | /usr/local/lib/node_modules/npm/lib/npm.js:59
14 | throw new Error('npm.load() required')
15 | ^
16 |  
17 | Error: npm.load() required
18 | at Object.get (/usr/local/lib/node_modules/npm/lib/npm.js:59:13)
19 | at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:32)
20 | at process.emit (events.js:197:13)
21 | at process._fatalException (internal/process/execution.js:127:25)

This implies that the environment variable NPM_TOKEN is not set.

This does not necessary happen randomly. It always happens when I open a pull request.
Thus always when the build says something like "Pfeifenjoy opened pull request #16 to master".
Otherwise it works.

@bradrydzewski
Copy link

bradrydzewski commented Feb 22, 2019

hey there, per our issue template, we provide end-user support at discourse.drone.io and at gitter.im/drone/drone. Thanks!

edit we also provide a guide that you can use to debug, which also lists the required information you will need to provide to get support (at the top of the document):
https://discourse.drone.io/t/problems-with-secrets/3286

@harness harness locked and limited conversation to collaborators Feb 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants