0

My goal is to deploy my python script from GitHub to my virtual machine via Azure Pipeline. I have established the connection, but I don't know, how clone the GitHub repository to the virtual machine. I have followed the instructions here

There is a example azure-pipeline.yml, which has the following:

jobs: 
    - deployment: VMDeploy
      displayName: Test_script
      environment:
        name: deploymentenvironment
        resourceType: VirtualMachine
      strategy:
          rolling:
            maxParallel: 2  #for percentages, mention as x%
            preDeploy:
              steps:
              - download: current
                artifact: drop
              - script: echo initialize, cleanup, backup, install certs
            deploy:
              steps:
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                    # Modify deployment script based on the app type
                    echo "Starting deployment script run"
                    sudo java -jar '$(Pipeline.Workspace)/drop/**/target/*.jar'
            routeTraffic:
              steps:
              - script: echo routing traffic
            postRouteTraffic:
              steps:
              - script: echo health check post-route traffic
            on:
              failure:
                steps:
                - script: echo Restore from backup! This is on failure
              success:
                steps:
                - script: echo Notify! This is on success

What should I put to the deploy part in order to make the deployment work? I would like to clone my script from GitHub to a specific folder and start it immediately. I assume that this part is all I need to modify:

# Modify deployment script based on the app type
  echo "Starting deployment script run"
  sudo java -jar '$(Pipeline.Workspace)/drop/**/target/*.jar'
pentti
  • 95
  • 10

1 Answers1

0

When you create a new pipeline in Azure DevOps, walk through the steps of the wizard by first selecting GitHub as the location of your source code. You might be redirected to GitHub to sign in. If so, enter your GitHub credentials. When the list of repositories appears, select your repository. You might be redirected to GitHub to install the Azure Pipelines app. If so, select Approve and install. Then during build, the repo will be downloaded to $(Agent.BuildDirectory).

enter image description here

To run Python scripts in your repository, use a script element and specify a filename. For example:

- script: python src/example.py

More details, you can refer to the documentation below: https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • Thanks. This solved the issue in to some extent. However, I faced a new issue, which is described in my last answer. – pentti Aug 10 '20 at 13:06