我试图创建一个构建管道,然后部署在我的临时服务器和Live服务器上。
trigger:
- main
variables:
uiSource: 'dashboard'
pool:
vmImage: 'windows-2019'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
pushd $(uiSource)
npm install
npm run build
popd
displayName: 'npm install and build'
- task: PublishPipelineArtifact@0
displayName: 'Publish pipeline artifact'
inputs:
artifactName: 'myArtifact'
targetPath: '$(Build.ArtifactStagingDirectory)'
我尝试添加,但这只是复制目录中的所有内容。我只对生成的构建感兴趣。
- task: CopyFiles@2
displayName: Copy file into artifacts
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
我尝试在VS代码中运行npm build,它工作正常,并创建了一个构建文件夹。构建的结果是手动部署的,工作正常。我只是试图在这里复制相同的内容
我已经更新到下面,但它现在生成一个空的zip文件
trigger:
batch: true
branches:
include:
- main
paths:
include:
- dashboard/*
pool:
vmImage: 'windows-2019'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
npm run build
displayName: 'npm install and build'
workingDirectory: 'dashboard/'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/FrontEnd.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
name: 'PublishArtifacts'
displayName: 'Publish Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'FrontEnd'
publishLocation: 'Container'
1条答案
按热度按时间lndjwyie1#
在
'npm install and build'
后,添加复制任务,并更改SourceFolder名称。如果在本地名为'build',则应为SourceFolder: 'build'
我通常使用zip和PublishBuildArtifacts@1。