Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PnP SPFx + JS SIG
trigger:
branches:
include:
- '*'
variables:
- group: office365credentials
stages:
- stage: Build
dependsOn: []
jobs:
- job: build_package
displayName: SPFx production build & packaging
steps:
- script: npm install
displayName: Install dependencies (NPM)
##########################################
## execute: gulp build
##########################################
- task: Gulp@0
displayName: SPFx build
inputs:
targets: build
##########################################
## execute: gulp bundle --ship
##########################################
- task: Gulp@0
displayName: SPFx bundle (production)
inputs:
targets: bundle
arguments: --ship
##########################################
## execute: gulp package-solution --ship
##########################################
- task: Gulp@0
displayName: SPFx package solution (production)
inputs:
targets: package-solution
arguments: --ship
##########################################
## determine name of generated *.sppkg
##########################################
- script: |
CMD_GET_SPPKG_NAME=$(find . -name '*.sppkg' -exec basename {} \;)
echo "##vso[task.setvariable variable=SpPkgFileName;isOutput=true]${CMD_GET_SPPKG_NAME}"
displayName: Get generated *.sppkg filename
name: GetSharePointPackage
##########################################
## publish *.sppkg as build artifact
##########################################
- task: PublishPipelineArtifact@1
displayName: Publish SharePoint package (*.sppkg)
inputs:
targetPath: $(Build.Repository.LocalPath)/sharepoint/solution/$(GetSharePointPackage.SpPkgFileName)
artifact: spfx-package
- stage: Test
dependsOn: []
jobs:
- job: run_tests
displayName: Execute tests
steps:
- script: npm install
displayName: Install dependencies (with NPM)
##########################################
## execute: gulp build
##########################################
- task: Gulp@0
displayName: SPFx build
inputs:
targets: build
##########################################
## execute tests
##########################################
- script: npm test
displayName: Run unit tests from test script (with NPM)
continueOnError: true
##########################################
## publish code coverage results to devops pipeline run
##########################################
- task: PublishCodeCoverageResults@1
displayName: Publish code coverage results
inputs:
codeCoverageTool: cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
##########################################
## publish junit test results to devops pipeline run
##########################################
- task: PublishTestResults@2
displayName: Publish test results
inputs:
testResultsFormat: JUnit
testResultsFiles: '**/junit.xml'
failTaskOnFailedTests: true
- stage: Deploy_Dev
dependsOn:
- Build
- Test
jobs:
- deployment: deploy_sppkg_dev
displayName: Deploy to development
environment: Development
strategy:
runOnce:
deploy:
steps:
##########################################
## install Office 365 CLI
##########################################
- script: sudo npm install --global @pnp/office365-cli
displayName: Install Office365 CLI
##########################################
## login to Office 365 CLI
##########################################
- script: o365 login https://voitanosdev.sharepoint.com/sites/SPFx-DevOps-DevEnv --authType password --userName $(AdminUserLogin) --password $(AdminUserPassword)
displayName: Login to Office365
##########################################
## download previously built *.sppkg
##########################################
- task: DownloadPipelineArtifact@2
displayName: Download SharePoint package (*.sppkg)
inputs:
buildType: current
artifactName: spfx-package
##########################################
## determine name of generated *.sppkg
##########################################
- script: |
CMD_GET_SPPKG_NAME=$(find $(Pipeline.Workspace)/spfx-package -name '*.sppkg' -exec basename {} \;)
echo "##vso[task.setvariable variable=SpPkgFileName;isOutput=true]${CMD_GET_SPPKG_NAME}"
displayName: Get generated *.sppkg filename
name: GetSharePointPackage
##########################################
## upload *.sppkg to the target app catalog
##########################################
- script: o365 spo app add --filePath "$(Pipeline.Workspace)/spfx-package/$(GetSharePointPackage.SpPkgFileName)" --appCatalogUrl https://voitanosdev.sharepoint.com/sites/SPFx-DevOps-DevEnv --scope sitecollection --overwrite --skipFeatureDeployment
displayName: Upload SharePoint package to Site Collection App Catalog
##########################################
##
##########################################
- script: o365 spo app deploy --name $(GetSharePointPackage.SpPkgFileName) --appCatalogUrl https://voitanosdev.sharepoint.com/sites/SPFx-DevOps-DevEnv --scope sitecollection --skipFeatureDeployment
displayName: Deploy SharePoint package
- deployment: deploy_sppkg_prod
displayName: Deploy to production
environment: Production
strategy:
runOnce:
deploy:
steps:
##########################################
## install Office 365 CLI
##########################################
- script: sudo npm install --global @pnp/office365-cli
displayName: Install Office365 CLI
##########################################
## login to Office 365 CLI
##########################################
- script: o365 login https://voitanosdev.sharepoint.com/sites/SPFx-DevOps-ProdEnv --authType password --userName $(AdminUserLogin) --password $(AdminUserPassword)
displayName: Login to Office365
##########################################
## download previously built *.sppkg
##########################################
- task: DownloadPipelineArtifact@2
displayName: Download SharePoint package (*.sppkg)
inputs:
buildType: current
artifactName: spfx-package
##########################################
## determine name of generated *.sppkg
##########################################
- script: |
CMD_GET_SPPKG_NAME=$(find $(Pipeline.Workspace)/spfx-package -name '*.sppkg' -exec basename {} \;)
echo "##vso[task.setvariable variable=SpPkgFileName;isOutput=true]${CMD_GET_SPPKG_NAME}"
displayName: Get generated *.sppkg filename
name: GetSharePointPackage
##########################################
## upload *.sppkg to the target app catalog
##########################################
- script: o365 spo app add --filePath "$(Pipeline.Workspace)/spfx-package/$(GetSharePointPackage.SpPkgFileName)" --appCatalogUrl https://voitanosdev.sharepoint.com/sites/SPFx-DevOps-ProdEnv --scope sitecollection --overwrite --skipFeatureDeployment
displayName: Upload SharePoint package to Site Collection App Catalog
##########################################
##
##########################################
- script: o365 spo app deploy --name $(GetSharePointPackage.SpPkgFileName) --appCatalogUrl https://voitanosdev.sharepoint.com/sites/SPFx-DevOps-ProdEnv --scope sitecollection --skipFeatureDeployment
displayName: Deploy SharePoint package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.