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

npm version not working in azure pipeline #1925

Closed
marc-wilson opened this issue Nov 7, 2018 · 5 comments
Closed

npm version not working in azure pipeline #1925

marc-wilson opened this issue Nov 7, 2018 · 5 comments

Comments

@marc-wilson
Copy link

marc-wilson commented Nov 7, 2018

Having issue with YAML?

Log issue at Azure-Pipelines-Yaml, it contains YAML templates and samples for Azure Pipelines. Also a place for the community to share best practices, ideas, and so on. File suggestions and issues here if they're specific to YAML pipelines.

Having issue with Tasks?

Log issue at Azure-Pipelines-Tasks, it contains all of the inbox tasks we ship with Azure-Pipelines/VSTS/TFS. If you are having issues with tasks in Build/Release jobs (e.g. unreasonable task failure) please log an issue there.

Having issue with software on Hosted Agent?

Log issue at Hosted Agent Image Repository, it contains the VM image used in the VSTS Hosted Agent Pool. If you are having Build/Release failures that seems like they are related to software installed on the Hosted Agent (e.g. the DotnetSDK is missing or the AzureSDK is not on the latest version) please log an issue there.

Having generic issue with Azure-Pipelines/VSTS/TFS?

Please report it to the Developer Community

Have you tried trouble shooting?

Trouble shooting doc

Agent Version and Platform

Version of your agent? 2.102.0/2.100.1/...

OS of the machine running the agent? OSX/Windows/Linux/...

VSTS Type and Version

VisualStudio.com or On-Prem TFS?

If On-Prem TFS, which release? 2015 RTM/QU1/QU2/...

If VisualStudio.com, what is your account name? http://account.visualstudio.com

What's not working?

Please include error messages and screenshots.

I have a build pipeline that I'm trying to run an npm publish in. Before I publish, I want to increase the version number using npm version path. Doing so bumps the version and then commits that update back to the branch. It seems azure piplines cannot handle this as it bombs out running the git commit ... portion. I'm assuming I can put in some sort of auth token, but I'm not seeing it anywhere. I have followed the below articles and nothing has worked. Everything runs fine locally. It just doesn't work in the pipeline.

https://stackoverflow.com/questions/38670306/executing-git-commands-inside-a-build-job-in-visual-studio-team-services-was-vs/38731565#38731565

https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/git-commands?view=vsts&tabs=yaml

I have also granted contribute access to the build agent as well (like the articles say to do). From the error message, it seems like git wants me to configure my global settings (name/email). I'm not sure how to go about that with the new Azure Pipeline Yaml setup. I see no option to switch to a visual designer mode (which I'm not sure would help me at all).

Error:

2018-11-07T20:49:11.2100940Z [command]/opt/hostedtoolcache/node/8.12.0/x64/bin/npm run prerelease
2018-11-07T20:49:11.4100619Z
2018-11-07T20:49:11.4101696Z npm ERR! code 128
2018-11-07T20:49:11.4102474Z npm ERR! Command failed: git commit -m 1.0.1-alpha.0
2018-11-07T20:49:11.4102671Z npm ERR!
2018-11-07T20:49:11.4102823Z npm ERR! *** Please tell me who you are.
2018-11-07T20:49:11.4102940Z npm ERR!
2018-11-07T20:49:11.4103228Z npm ERR! Run
2018-11-07T20:49:11.4103493Z > @scope/package@1.0.0 prerelease /home/vsts/work/1/s
2018-11-07T20:49:11.4103904Z npm ERR!
2018-11-07T20:49:11.4104187Z > npm version prerelease --preid=alpha
2018-11-07T20:49:11.4105120Z npm ERR! git config --global user.email "you@example.com"
2018-11-07T20:49:11.4105153Z
2018-11-07T20:49:11.4106401Z npm ERR! git config --global user.name "Your Name"
2018-11-07T20:49:11.4106773Z v1.0.1-alpha.0
2018-11-07T20:49:11.4107616Z npm ERR!
2018-11-07T20:49:11.4108781Z npm ERR! to set your account's default identity.
2018-11-07T20:49:11.4110153Z npm ERR! Omit --global to set the identity only in this repository.
2018-11-07T20:49:11.4111020Z npm ERR!
2018-11-07T20:49:11.4112300Z npm ERR! fatal: empty ident name (for ) not allowed
2018-11-07T20:49:11.4113056Z npm ERR!
2018-11-07T20:49:11.4114130Z
2018-11-07T20:49:11.4114974Z npm ERR! A complete log of this run can be found in:
2018-11-07T20:49:11.4116557Z npm ERR! /home/vsts/.npm/_logs/2018-11-07T20_49_11_309Z-debug.log
2018-11-07T20:49:11.4117409Z npm ERR! code ELIFECYCLE
2018-11-07T20:49:11.4118095Z npm ERR! errno 1
2018-11-07T20:49:11.4119144Z npm ERR! @scope/package@1.0.0 prerelease: npm version prerelease --preid=alpha
2018-11-07T20:49:11.4119906Z npm ERR! Exit status 1
2018-11-07T20:49:11.4120810Z npm ERR!
2018-11-07T20:49:11.4122312Z npm ERR! Failed at the @scope/package@1.0.0 prerelease script.
2018-11-07T20:49:11.4123297Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-11-07T20:49:11.4123903Z npm WARN Local package.json exists, but node_modules missing, did you mean to install?
2018-11-07T20:49:11.4124608Z
2018-11-07T20:49:11.4125206Z npm ERR! A complete log of this run can be found in:
2018-11-07T20:49:11.4126559Z npm ERR! /home/vsts/.npm/_logs/2018-11-07T20_49_11_391Z-debug.log

Here is my prerelease script:

"prerelease": "npm version prerelease --preid=alpha"

Here is my YAML:

pool:
  vmImage: 'Ubuntu 16.04'

steps:
- checkout: self
  clean: true
  persistCredentials: true
- task: NodeTool@0
  inputs:
    versionSpec: '8.x'
  displayName: 'Install Node.js'
- task: Npm@1
  displayName: 'Increase Version'
  inputs:
    command: custom
    verbose: false
    customCommand: 'run prerelease'
- task: Npm@1
  displayName: 'npm install'
  inputs:
    verbose: false
    customRegistry: useFeed
    customFeed: '<guid>'
- task: Npm@1
  displayName: 'Build Module'
  inputs:
    command: custom
    verbose: false
    customCommand: 'run build'
- task: Npm@1
  displayName: 'Package Module'
  inputs:
    PathToPublish: dist
- task: Npm@1
  displayName: 'Publish package'
  inputs:
    command: publish
    verbose: false
    publishRegistry: useFeed
    publishFeed: '<guid>'

Node.js

Build a general Node.js project with npm.

Add steps that analyze code, save build artifacts, deploy, and more:

https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

Agent and Worker's Diagnostic Logs

Logs are located in the agent's _diag folder. The agent logs are prefixed with Agent_ and the worker logs are prefixed with Worker_. All sensitive information should already be masked out, please double check before pasting here.

@TingluoHuang
Copy link
Contributor

@dakale did we not set git username/email on the hosted ubuntu image?
@mswilson4040 you can set git user/email as part of your yaml

steps:
- checkout: self
  clean: true
  persistCredentials: true
- task: NodeTool@0
  inputs:
    versionSpec: '8.x'
  displayName: 'Install Node.js'
- script: |
    git config user.email "you@example.com" 
    git config user.name "Your Name"
- task: Npm@1
  displayName: 'Increase Version'
  inputs:
    command: custom
    verbose: false
    customCommand: 'run prerelease'

@dakale
Copy link
Contributor

dakale commented Nov 8, 2018

Theres no default config for the git install on hosted ubuntu. I havent seen a common way to provide a default here since its user specific. Does the agent do configuration based on the user running the build? It might be possible to write the system wide git config at that point

@TingluoHuang
Copy link
Contributor

@dakale the agent doesn't care, since it's doing git fetch only. :)

@marc-wilson
Copy link
Author

Thanks, guys. I added what @TingluoHuang suggested and that got the build to pass. The versioning is also working as expected. I think what would be most helpful here is to provide an area within Azure Devops to configure an account that the git config would use. I'm not sure if that's possible or not, but it'd be nice to have one account doing things rather than having to remember to put in the git config directly within the yaml pipeline.

In any case, @TingluoHuang suggestion solved my issue..

@TingluoHuang
Copy link
Contributor

i am going to close this issue as it is not an actual agent issue and the question has be answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants