zuul-jobs/roles/upload-npm/tasks/main.yaml
Jeremy Stanley 8b577d4106 Change to the executor workdir during npm upload
When using npm to install locally, it wants to write a node_modules
tree in the current path. Since the default path of a command is the
path where the playbook resides and this is not writeable on a zuul
executor, change to the writeable workdir first.

Change-Id: Ib4f632c0b9e3f5842e3cd649b6ca7ecb8042e7e3
2017-12-09 17:27:56 +00:00

28 lines
817 B
YAML

# This is not optimized, but allows for getting a version of node in the
# home dir.
- name: Create .npmrc configuration file
template:
dest: "~/.npmrc"
mode: 0400
src: .npmrc.j2
- name: Install NVM
git:
repo: 'https://github.com/creationix/nvm'
dest: '~/.nvm'
version: v0.33.5
- name: Upload tarball to npm
args:
chdir: "{{ zuul.executor.work_root }}"
shell:
executable: /bin/bash
cmd: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm install node
nvm use node
# Workaround for https://github.com/npm/npm/issues/16723
npm install npm@4
node_modules/.bin/npm publish --ignore-scripts {{ zuul.executor.work_root }}/artifacts/{{ zuul.project.short_name }}-{{ project_ver }}.tar.gz