### Complete Ruby pipeline example Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/ruby.md A complete azure-pipelines.yml file demonstrating Ruby pipeline setup, including triggering, build environment, Ruby version, dependency installation, test execution, and publishing results. ```yaml # Ruby pipeline example trigger: - main pool: vmImage: 'ubuntu-latest' variables: rubyVersion: '3.4.7' steps: - task: UseRubyVersion@0 inputs: versionSpec: '$(rubyVersion)' addToPath: true displayName: 'Set Ruby version to $(rubyVersion)' - script: | gem install bundler bundle install --retry=3 --jobs=4 displayName: 'Install dependencies' - script: bundle exec rake displayName: 'Run tests with Rake' - task: PublishTestResults@2 condition: succeededOrFailed() inputs: testResultsFiles: '**/test-*.xml' testRunTitle: 'Ruby tests' displayName: 'Publish test results' - task: PublishCodeCoverageResults@2 inputs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/coverage' failIfCoverageEmpty: true displayName: 'Publish code coverage' ``` -------------------------------- ### Install and start the agent as a service Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/enterprise-live-migrations/start-migration.md Install and start the self-hosted agent as a service to ensure it remains online across reboots. This requires sudo privileges. ```bash sudo ./svc.sh install sudo ./svc.sh start ``` -------------------------------- ### Example of queuing a migration Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/migrate/migration-test-run.md This is a concrete example of the 'import' command, showing a specific path to the migration specification file. Ensure the path is correct for your setup. ```cmd Migrator import /importFile:C:\DataMigrationToolFiles\migration.json ``` -------------------------------- ### Secure Installation Script Best Practices Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/apps/cd/azure/deploy-virtual-scale-set-java.md Implement security best practices in your installation script, such as exiting on error, using `pipefail`, minimizing `sudo` usage, and only performing necessary operations for application setup. ```bash #!/bin/bash set -e # Exit on any error set -o pipefail # Exit if any command in pipeline fails # Only run operations necessary for application setup # Avoid unnecessary sudo where possible echo "Installing application dependencies..." # Add your installation commands here ``` -------------------------------- ### Full Dockerfile Example Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/process/container-phases.md This Dockerfile sets up a Node.js 18 Alpine environment, installs build dependencies, and configures the agent handler path. ```dockerfile FROM node:18-alpine RUN apk add --no-cache --virtual .pipeline-deps readline linux-pam \ && apk add bash sudo shadow \ && apk del .pipeline-deps LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/local/bin/node" CMD [ "node" ] ``` -------------------------------- ### Initialize Git Repository and Create File Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/git/git-log-history-simplification.md Initializes a new Git repository and creates the first file. This is the starting point for the history simplification example. ```Git CLI > cd sample > git init > echo "some content" > test.txt > git add test.txt > git commit -m "Initial commit" ``` -------------------------------- ### Start the agent interactively Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/enterprise-live-migrations/start-migration.md Use this command to start the self-hosted agent interactively on a Linux machine. Ensure the agent is installed and you are in the agent's directory. ```bash ./run.sh ``` -------------------------------- ### Get Help on Agent Configuration Options Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/agents/includes/v3/configure-help-unix.md View all available options for configuring the agent, including authentication methods and unattended setup parameters. This command is useful for understanding the full range of configuration possibilities. ```bash ./config.sh --help ``` -------------------------------- ### Test on Android Emulator Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/android.md Configure a Bash task to install system images, create an Android Virtual Device (AVD), and start the emulator in the background. Ensure you use a macOS agent with hardware acceleration for hosted agents. ```yaml - task: Bash@3 inputs: targetType: 'inline' script: | #!/usr/bin/env bash echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-35;google_apis;x86_64' echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n xamarin_android_emulator -d "Nexus 10" -k 'system-images;android-35;google_apis;x86_64' --force echo "y" | $ANDROID_HOME/emulator/emulator -list-avds echo "Starting emulator" nohup $ANDROID_HOME/emulator/emulator -avd xamarin_android_emulator -no-snapshot -no-window -no-audio -no-boot-anim -accel on > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d "\r") ]]; do sleep 1; done; input keyevent 82' $ANDROID_HOME/platform-tools/adb devices echo "Emulator started" ``` -------------------------------- ### Specify installation target version range Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/extend/develop/manifest.md Use the `version` field to specify a version range for installation targets like `Microsoft.VisualStudio.Services`. This example targets Azure DevOps starting from version 15.0. ```json { "targets": [ { "id": "Microsoft.VisualStudio.Services", "version": "[15.0,)" } ] } ``` -------------------------------- ### Install Sample NuGet Package Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/artifacts/includes/nuget/publish.md Installs the 'HelloWorld' sample NuGet package. This is useful for practicing package publishing workflows without needing an existing package. ```Command nuget install HelloWorld -ExcludeVersion ``` -------------------------------- ### Example: Add source and publish package Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/artifacts/nuget/publish.md This example demonstrates adding a package source with a PAT and then publishing a NuGet package to that source. ```CLI nuget sources Add -Name "MySource" -Source https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyFeed/nuget/v3/index.json -UserName MyUserName -Password YourPersonalAccessToken -config ./nuget.config nuget push nupkgs/mypackage.1.1.8.nupkg -src MySource -ApiKey AZ ``` -------------------------------- ### Process Template Version GUID Example Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/organizations/settings/work/import-process/resolve-errors.md Shows an example of a ProcessTemplate.xml file specifying a version GUID that conflicts with a locked process. ```xml Fabrikam Agile Use this template to support Fabrikam Agile planning methods. ``` -------------------------------- ### Example WIT Import Command Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/reference/add-wits-to-backlogs-and-boards.md An example of the `witadmin importwitd` command, demonstrating how to import the 'ServiceApp' WIT with specific collection and project details. ```Command Line witadmin importwitd /collection:"http://MyServer:8080/tfs/DefaultCollection"/p:MyProject /f:"DirectoryPath/ServiceApp.xml" ``` -------------------------------- ### Initialize extension and install SDK Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/extend/develop/add-hub.md Create a new directory for your extension, initialize it with npm, and install the Azure DevOps extension SDK. ```bash mkdir my-hub-extension cd my-hub-extension npm init -y npm install azure-devops-extension-sdk --save ``` -------------------------------- ### Add wiki page with inline content using Azure DevOps CLI Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/project/wiki/add-edit-wiki.md Create a new wiki page with specified content directly in the command. This example adds a page titled 'Get Started' to 'MyProjectwiki' with provided markdown content. ```azurecli az devops wiki page update --path 'Get Started' --wiki MyProjectwiki --content "**Contributor Support**
TODO: Add introduction" ``` -------------------------------- ### Start Linux Agent Service Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/agents/linux-agent.md Starts the agent service after it has been installed. ```bash sudo ./svc.sh start ``` -------------------------------- ### Process Template Valid Version GUID Example Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/organizations/settings/work/import-process/resolve-errors.md Provides an example of a ProcessTemplate.xml file with a unique and valid version GUID, resolving potential conflicts with locked processes. ```xml Fabrikam Agile Use this template to support Fabrikam Agile planning methods. ``` -------------------------------- ### Register QEMU and build image Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/containers/build-image.md Run this script before building your image to register the QEMU binary for multi-architecture support. ```Shell # register QEMU binary - this can be done by running the following image docker run --rm --privileged multiarch/qemu-user-static --reset -p yes # build your image ``` -------------------------------- ### Install Go dependencies using go get Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/go.md Downloads the source code for a Go project or installs a tool into the Go workspace using the `go get` command. This is a common step for managing Go project dependencies. ```yaml - script: go get -v -t -d ./... workingDirectory: '$(modulePath)' displayName: 'go get dependencies' ``` -------------------------------- ### Selenium Test Project Example Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/test/continuous-test-selenium.md This C# code demonstrates a basic Selenium test class for testing the Bing.com website. It includes setup for different browsers (Chrome, Firefox, IE) and a test method to perform a search and verify the title. Ensure you have the necessary Selenium WebDriver packages installed. ```csharp using System; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.IE; namespace SeleniumBingTests { /// /// Summary description for MySeleniumTests /// [TestClass] public class MySeleniumTests { private TestContext testContextInstance; private IWebDriver driver; private string appURL; public MySeleniumTests() { } [TestMethod] [TestCategory("Chrome")] public void TheBingSearchTest() { driver.Navigate().GoToUrl(appURL + "/"); driver.FindElement(By.Id("sb_form_q")).SendKeys("Azure Pipelines"); driver.FindElement(By.Id("sb_form_go")).Click(); driver.FindElement(By.XPath("//ol[@id='b_results']/li/h2/a/strong[3]")).Click(); Assert.IsTrue(driver.Title.Contains("Azure Pipelines"), "Verified title of the page"); } /// ///Gets or sets the test context which provides ///information about and functionality for the current test run. /// public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } [TestInitialize()] public void SetupTest() { appURL = "http://www.bing.com/"; string browser = "Chrome"; switch(browser) { case "Chrome": driver = new ChromeDriver(); break; case "Firefox": driver = new FirefoxDriver(); break; case "IE": driver = new InternetExplorerDriver(); break; default: driver = new ChromeDriver(); break; } } [TestCleanup()] public void MyTestCleanup() { driver.Quit(); } } } ``` -------------------------------- ### Example prepare command for Fabrikam Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/migrate/migration-test-run.md An example of the `prepare` command used by the Fabrikam corporation, demonstrating the inclusion of collection URL, tenant domain name, region, and connection string. ```cmd Migrator prepare /collection:http://fabrikam:8080/DefaultCollection /tenantDomainName:fabrikam.OnMicrosoft.com /region:{region} /connectionString:"Data Source=fabrikam;Initial Catalog=Configuration;Integrated Security=True" ``` -------------------------------- ### Install npm Packages for JavaScript Project Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/security/github-advanced-security-dependency-scanning-troubleshoot.md Ensure a package install step precedes the dependency scanning task for JavaScript projects. This example uses the Npm task to install packages. ```yaml - task: Npm@1 displayName: 'npm install' inputs: command: 'install' workingDir: '$(System.DefaultWorkingDirectory)' - task: AdvancedSecurity-Dependency-Scanning@1 ``` -------------------------------- ### Show Specific Wiki and Open in Browser Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/project/wiki/manage-wikis.md This example demonstrates how to show the details of a wiki named 'myprojectwiki' and open it directly in the web browser. ```azurecli az devops wiki show --wiki myprojectwiki --open ``` -------------------------------- ### Install Anaconda packages Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/anaconda.md Install packages, such as `scipy`, into a specified conda environment. This example activates the environment before installing the package. Note the use of `call` for Windows to ensure script continuation. ```yaml - bash: | conda activate myEnvironment conda install --yes --quiet --name myEnvironment scipy displayName: Install Anaconda packages ``` ```yaml - script: | call activate myEnvironment conda install --yes --quiet --name myEnvironment scipy displayName: Install Anaconda packages ``` -------------------------------- ### Get Azure DevOps Repository GUID Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/enterprise-live-migrations/troubleshoot.md Retrieve the unique GUID for an Azure DevOps repository. This is often needed for migration commands. ```bash az repos show --org --project --repository --query id -o tsv ``` -------------------------------- ### Get Azure DevOps Repository GUID using CLI Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/enterprise-live-migrations/prerequisites.md Use the Azure DevOps CLI to retrieve the unique identifier (GUID) for a specific repository. This GUID is required when initiating an Enterprise Live Migration. ```azurecli az repos show --repository --query id -o tsv ``` -------------------------------- ### Initialize npm project Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/git/create-pr-status-server.md Run this command to create a package.json file for your Node.js project. Accept defaults, but change the entry point to 'app.js'. ```bash npm init ``` -------------------------------- ### Display Help for Agent Configuration Options Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/agents/windows-agent.md Run this command to view all available options for agent configuration, including authentication alternatives and unattended setup. This command lists the latest required and optional responses. ```powershell .\config --help ``` -------------------------------- ### Customize runsvc.sh for Service Start Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/agents/osx-agent.md Modify the `runsvc.sh` script to include custom instructions or commands that should run when the agent service starts. This is useful for environment setup. ```bash # insert anything to setup env when running as a service ``` -------------------------------- ### Example package.json for Scoped Package Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/artifacts/npm/scopes.md An example package.json file for a scoped package, including name, version, and description. ```json { "name": "@demo/js-e2e-express-server", "version": "2.0.0", "description": "JavaScript server written with Express.js", "main": "index.js", "directories": { "doc": "docs", "test": "test" } } ``` -------------------------------- ### Example: Update Iteration Dates with Azure CLI Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/organizations/settings/set-iteration-paths-sprints.md This example demonstrates updating the start and end dates for a specific iteration path within a project using the Azure CLI. The output is formatted as a table. ```azurecli az boards iteration project update --path "\Fabrikam Fiber\Iteration\Release 1\Sprint 3" --finish-date 2019-08-31 --start-date 2019-08-01 --project "Fabrikam Fiber" --output table ``` -------------------------------- ### Example SQL Authentication and Role Assignment Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/migrate/migration-prepare-test-run.md An example demonstrating how to set the recovery model, create a SQL login and user, and assign the 'TFSEXECROLE' role for a database named 'Foo'. ```sql ALTER DATABASE [Foo] SET RECOVERY SIMPLE; USE [Foo] CREATE LOGIN fabrikam WITH PASSWORD = 'fabrikampassword' CREATE USER fabrikam FOR LOGIN fabrikam WITH DEFAULT_SCHEMA=[dbo] EXEC sp_addrolemember @rolename='TFSEXECROLE', @membername='fabrikam' ``` -------------------------------- ### Get Tomcat Spring Petclinic Repository URL Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/java-webapp.md Use this GitHub repository URL for the Tomcat runtime example. ```text https://github.com/spring-petclinic/spring-framework-petclinic ``` -------------------------------- ### SqlPackage.exe Help Command Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/targets/azure-sqldb.md Displays help information for a specific SqlPackage.exe action. ```command sqlpackage.exe /Action:Extract /? ``` ```command sqlpackage.exe /Action:Publish /? ``` ```command sqlpackage.exe /Action:Export /? ``` ```command sqlpackage.exe /Action:Import /? ``` ```command sqlpackage.exe /Action:DeployReport /? ``` ```command sqlpackage.exe /Action:DriftReport /? ``` -------------------------------- ### Get help for the prepare command Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/migrate/migration-test-run.md Run this command to display help documentation for the `Migrator prepare` command, including instructions for local and remote execution. ```cmd Migrator prepare /help ``` -------------------------------- ### Extension directory structure Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/extend/get-started/node.md An example of the expected file structure for your Azure DevOps extension after completing the initial setup. ```text |-- my-hub.html |-- node_modules |-- @types |-- azure-devops-extension-sdk |-- package.json |-- vss-extension.json ``` -------------------------------- ### Example: Show PR details and open in browser Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/git/view-pull-requests.md This example demonstrates how to view the details of pull request #21, display the output as a table, and open the pull request in your web browser. ```azurecli az repos pr show --id 21 --open --output table ``` -------------------------------- ### Fetch Work Items with Queries Programmatically Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/boards/includes/rest-apis-queries.md A quickstart guide on how to fetch work items using queries programmatically. ```APIDOC ## Fetch Work Items with Queries Programmatically ### Description This quickstart guide provides instructions and examples on how to programmatically fetch work items from Azure DevOps using queries. It demonstrates how to integrate with the Azure DevOps API to retrieve specific work items based on defined query criteria. ### Documentation Link [Fetch work items with queries programmatically](../../integrate/quickstarts/work-item-quickstart.md) ``` -------------------------------- ### Get Java SE Spring Petclinic Repository URL Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/pipelines/ecosystems/java-webapp.md Use this GitHub repository URL for the Java SE runtime example. ```text https://github.com/spring-projects/spring-petclinic ``` -------------------------------- ### Initialize a new Git repository Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/repos/git/creatingrepo.md Run this command in an empty folder to create a new local Git repository. Ensure Git is installed and accessible from your command prompt. ```console > git init ``` -------------------------------- ### Get help for the import command Source: https://github.com/microsoftdocs/azure-devops-docs/blob/main/docs/migrate/migration-test-run.md Run this command to see guidance and help for the 'import' command of the Data Migration Tool. This is useful for understanding the command's options and usage. ```cmd Migrator import /help ```