【发布时间】:2019-10-28 01:00:58
【问题描述】:
我正在尝试使用 Azure DevOps 在 git 页面中部署我的 react 应用程序(只是一个非常基本的应用程序)。这是为了让我亲身体验 Azure Devops。
首先我如下配置了我的packag.json。
{
"name": "gitpages",
"version": "0.1.0",
"homepage": "https://senal.github.io/gitpage-react",
"private": true,
"dependencies": {
"gh-pages": "^2.0.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
请注意“主页”和“部署”脚本。
在我的 Azure DevOps 中,我修改了 yml 文件,如下所示。
# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
git config --global user.email "xxxx.yyyy@mymail.com"
git config --global user.name "RSF"
npm install
npm run build
npm run deploy
displayName: 'npm install and build then deploy'
但是,当我在 DevOps 中运行构建时,我收到以下错误:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gitpages@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gitpages@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vsts/.npm/_logs/2019-06-13T12_03_34_094Z-debug.log
##[error]Bash exited with code '1'.
请建议我的步骤/脚本有什么问题。
如果您需要更多信息,请随时与我联系。
更新:我能够通过运行来创建页面
npm 运行部署
从我的终端。
我想知道的是,为什么我们不能在 DevOps 中做同样的事情?
干杯, 无国界医生
【问题讨论】:
标签: reactjs azure-devops github-pages