skip to Main Content

Here is my configuration I use to build and deploy my pipeline:

stages:
- stage: BuildAndPush
  displayName: Build Docker Image
  pool:
    vmImage: 'ubuntu-latest'
  [...]
    
- stage: Deployment
  displayName: Deployment
  condition: succeeded()
  jobs:
  - deployment:
    displayName: Deploy on ${{variables.environment}} environment
    environment: ${{variables.environment}}
    strategy: 
      runOnce:
        deploy:
          steps:
          - task: Bash@3
            displayName: List Artifacts
            inputs:
              targetType: 'inline'
              script: echo "HOSTNAME= $HOSTNAME"

Regarding my Environment, my resource gets never deployed:

Environment - Resources
Environment - Deployments

I expect my Deploymment stage to run on my onprem VM directly however it doesn’t.
How can I change this behavior? As today all deployment pipeline are running on a hosted Azure VM instead.

3

Answers


  1. Chosen as BEST ANSWER

    Thanks to both to putting me on the good tracks.

    Solution was actually simpler than I thought, simply precise on which resource name you want to deploy by extending the environment part:

      jobs:
      - deployment:
        displayName: Deploy on ${{variables.environment}} environment
        environment: 
          name: ${{variables.environment}}
          resourceName: ${{parameters.vmToDeploy}} ## HERE !!!
          resourceType: VirtualMachine
    

  2. Maybe you are looking for the below solution,

    If the stage need to run in an on premise PC first of all need to add the Self-Hosted Agents (These are created and managed by the Customer) in Azure DevOps, The instruction in the below link,
    https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops

    After add the Self-Hosted Agents define the pool in stage,

    stage: Deployment
      displayName: Deployment
      condition: succeeded()
      jobs:
      - deployment:
        displayName: Deploy on ${{variables.environment}} environment
        environment: ${{variables.environment}}
        **pool:
          vmImage: 'Your-Agent-Name'**
        strategy: 
          runOnce:
            deploy:
              steps:
              - task: Bash@3
                displayName: List Artifacts
                inputs:
                  targetType: 'inline'
                  script: echo "HOSTNAME= $HOSTNAME"
    
    Login or Signup to reply.
  3. Creating self-hosted agents(Windows or Linux) in Azure DevOps would be best. Self-hosted agents basically are build machines you use to run the pipeline.
    Specify the self-hosted agent in the YAML pipeline.

    Note: If you’re building a docker image, you need to install docker on the agent.

    STEPS:

    • Go to your project settings on Azure DevOps, In the pipeline section,
      create a self-hosted agent pool.
    • Inside the agent pool, click on New Agent to create a new
      agent.(Choose Windows, Linux or Mac).
    • Additionally, install docker in the agent
    • After creating the agent, specify the agent pool name in your
      pipeline
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search