Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 2, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 2, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 2, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 2, 2025

      How Red Hat just quietly, radically transformed enterprise server Linux

      June 2, 2025

      OpenAI wants ChatGPT to be your ‘super assistant’ – what that means

      June 2, 2025

      The best Linux VPNs of 2025: Expert tested and reviewed

      June 2, 2025

      One of my favorite gaming PCs is 60% off right now

      June 2, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      `document.currentScript` is more useful than I thought.

      June 2, 2025
      Recent

      `document.currentScript` is more useful than I thought.

      June 2, 2025

      Adobe Sensei and GenAI in Practice for Enterprise CMS

      June 2, 2025

      Over The Air Updates for React Native Apps

      June 2, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025
      Recent

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025

      Microsoft says Copilot can use location to change Outlook’s UI on Android

      June 2, 2025

      TempoMail — Command Line Temporary Email in Linux

      June 2, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Building Azure DevOps CI Pipelines for SPFx

    Building Azure DevOps CI Pipelines for SPFx

    December 31, 2024

    This blog offers a comprehensive guide to setting up Continuous Integration (CI) in Azure DevOps to automate the integration of SharePoint Framework (SPFx) code by leveraging Azure DevOps pipelines. This process aims to streamline development workflows, improve code quality, and ensure quicker code validation before deployment without any manual processing.

    Continuous Integration (CI) is the process of automating the build and testing of code when a developer commits changes to source control. Commit to source control triggers an automated build that grabs the latest code from version control, builds it, and runs tests on it (if configured).

    Prerequisite for Building CI pipeline for SPFx in Azure DevOps

    To set up Continuous Integration (CI) for SPFx in Azure DevOps, ensure you have the following things already setup:

    • An Azure DevOps account with required access
    • Your SharePoint Framework (SPFx) project should be stored in a Git repository
    • Ensure the repository includes the necessary package.json, gulpfile.js, and other configuration files required to build and bundle your SPFx solution

    Implementation

    To implement CI, we must create a new Pipeline in Azure DevOps. Building a pipeline includes the following major steps:

    • Create a build definition
    • Install NodeJS
    • Restore npm packages
    • Build the solution
    • Package the solution
    • Prepare the Artifacts
    • Publish the Artifacts

    Create a Build Definition

    Build definition contains the definition and configuration for the build. Follow the below steps to create a new build definition.

    • Login to Visual Studio Online (Azure DevOps)
    • Select your project to set up a build definition.
    • From the left navigation, click Pipelines > Builds.
    • Click “New pipeline” > Click on “Use the classic editor”.
    • Select “Azure Repos Git” > Select Team Project > Select Repository > Select branch for CI implementation.

    Selectsource

    • Under “Select a template”, select “Empty Pipeline”.

    Selecttemplate

    • The build definition has a default agent. We can add multiple tasks to the agent to define our build.

    Pipelinedetails

    In this case, in agent specification, I have used Windows-2022, but you can also choose “Windows-latest” based on the environment in which you want to run your build.

    Install NodeJS

    • On the default agent, click the + sign.
    • Search for “Node”.
    • Add Node.js tool installer.

    Addnodejstool

    • Make sure you specify 10.x in the Version Spec field. If your project is based on SharePoint Framework 1.7.1 or earlier, use version 8.x.

    Selectnotejsversion

    Restore npm Packages

    SharePoint Framework solution uses third-party npm packages. We need to restore those before starting the build process.

    • Add npm task.
    • Verify if the command is set to install.

    Npminstall

    Build the Solution

    Build the SPFx solution to minify the required assets to upload to CDN.

    • Add gulp task.
    • Set Gulp file path to gulpfile.js.
    • Set Gulp task as a bundle.
    • Set Gulp arguments to –ship.

    Buildsolution

    Note: Ensure the gulp task has the “–warnoff” command and “–ship” to avoid build failure in a production environment. Refer to the Configuration section below for details.

    Hostinger

    Package the Solution

    The next step is to combine the assets into a package.

    • Add gulp task.
    • Set Gulp file path to gulpfile.js.
    • Set Gulp task as package-solution.
    • Set Gulp arguments to –ship.

    Packagesolution

    Prepare the Artifacts

    Azure DevOps build does not retain any files. The “.sppkg” file created from the above step needs to be copied to the staging directory to be published to the release pipeline.

    • Add “Copy Files” task.
    • Set “Source Folder” to $(Build.Repository.LocalPath)/sharepoint/solution.
    • Set “Contents” to *.sppkg.
    • Set target folder to $(Build.ArtifactStagingDirectory)/drop.

    Setartifacts

    Publish the Artifacts

    Instruct Azure DevOps to keep the files after build execution.

    • Add the “Publish Build Artifacts” task.
    • Set “Path to publish” to $(Build.ArtifactStagingDirectory)/drop.
    • Set “Artifact name” to drop.

    Publishartifacts

    Configuration

    During bundling and packaging of your SharePoint Framework solution, you could see two types of messages:

    • Warnings
    • Errors

    When running a DEBUG build, both messages do not cause the process to fail by a stderr (or standard error). But in the PRODUCTION build, you would get the following type of error output:

    Stderrcicd

    This might be an issue in your automated build/release pipelines. For instance, when you automatically bundle and package your solution on Azure DevOps, there is no way to tell that it should continue when warnings occur. The only option you have is to “continue” on error.

    To restrict this, we can add a “warnoff” command in the build process, which won’t cause the build process to fail. For this, make the following changes in gulpfile.js.

    // Retrieve the current build config and check if there is a `warnoff` flag set
    const crntConfig = build.getConfig();
    const warningLevel = crntConfig.args["warnoff"];
    // Extend the SPFx build rig, and overwrite the `shouldWarningsFailBuild` property
    if (warningLevel) {
        class CustomSPWebBuildRig extends build.SPWebBuildRig {
            setupSharedConfig() {
                build.log("IMPORTANT: Warnings will not fail the build.")
                build.mergeConfig({
                    shouldWarningsFailBuild: false
                });
                super.setupSharedConfig();
            }
        }
        build.rig = newCustomSPWebBuildRig();
    }
    build.initialize(gulp)

    Conclusion

    Setting up a Continuous Integration (CI) pipeline for SPFx in Azure DevOps automates the process of building, testing, and bundling your SPFx solutions whenever any code changes occur. This pipeline will eventually reduce the need for manual intervention and guarantee that the latest code is thoroughly validated before deployment.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleMigration of DNS Hosted Zones in AWS
    Next Article Building Azure DevOps CD Processes for SPFx

    Related Posts

    Development

    A Beginner’s Guide to Graphs — From Google Maps to Chessboards

    June 2, 2025
    Development

    How to Code Linked Lists with TypeScript: A Handbook for Developers

    June 2, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Elpher is a gopher and gemini client for Emacs

    Linux

    Webinar: Securing the Modern Workspace: What Enterprises MUST Know about Enterprise Browser Security

    Development

    Unable to remove orphan mailbox from Outlook

    Operating Systems

    4 Steps to Automate your Procurement Process

    Artificial Intelligence

    Highlights

    Development

    I never expected this major force in horror movies to make games, but I’m sold after playing its first upcoming title

    June 27, 2024

    Blumhouse Games is a video games publisher subsidiary of the legendary horror movie company, and…

    Future-Proofing the Workforce: How Skilling is Cultivating Next-gen Tech Talent

    April 27, 2024

    A New Challenge for AI: Humanity’s Last Exam

    February 21, 2025

    SVAR Svelte UI Components: Our Experience of Migration to Svelte 5

    December 2, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.