elijd

Basic YAML pipeline for Python Function App

Sep 19th, 2020 (edited)
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.34 KB | None | 0 0
  1. trigger:
  2.   branches:
  3.     include:
  4.    # This will ensure that the pipeline is only triggered when the code changes are made to the 'master' branch.
  5.     - master
  6.   paths:
  7.     include:
  8.    # This will ensure that the pipeline is only triggered when coomits/PR contain changes in this particular
  9.     # folder. You can of course choose to omit this, if you always want it to trigger, regardless of what code
  10.     # is changed in the repository.
  11.     -  'source/code/path/*'
  12.  
  13. variables:
  14.   bin: '$(Build.BinariesDirectory)'
  15.   zip: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
  16.  
  17. jobs:
  18. - job: Build
  19.   displayName: Build
  20.   pool:
  21.    # You can use 'ubuntu-latest' here as well. Currently translates to 18.04. 20.04 is currently in preview,
  22.     # and I do not recommend using it (I used not long ago, and it was causing a lot of issues). If you go
  23.     # with 'ubuntu-latest', be prepared for a pipeline that'll potentially start breaking when 'latest'
  24.     # will translate to 20.04.
  25.     vmImage: ubuntu-18.04
  26.  
  27.   steps:
  28.   - task: DeleteFiles@1
  29.     inputs:
  30.      SourceFolder: '$(bin)'
  31.  
  32.   # I don't really know if this step is needed. I haven't built any python function apps, but it was part of the template file,
  33.   # so I thought it would be a good idea to include it here as well. If you know better, do with it whatever you want. :-)
  34.   - bash: |
  35.      if [ -f extensions.csproj ]
  36.       then
  37.           dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
  38.       fi
  39.     workingDirectory: $(bin)
  40.     displayName: 'Build extensions'
  41.  
  42.   # Functions V2 supports Python 3.6 as of today
  43.   - task: UsePythonVersion@0
  44.     displayName: 'Use Python 3.6'
  45.     inputs:
  46.       versionSpec: 3.6
  47.  
  48.   - bash: |
  49.      python -m venv worker_venv
  50.       source worker_venv/bin/activate
  51.       pip install -r requirements.txt
  52.     workingDirectory: $(bin)
  53.     displayName: 'Install application dependencies'
  54.  
  55.   - task: ArchiveFiles@2
  56.     displayName: 'Archive files'
  57.     inputs:
  58.       rootFolderOrFile: '$(bin)'
  59.       includeRootFolder: false
  60.       archiveType: zip
  61.       archiveFile: '$(zip)'
  62.       replaceExistingArchive: true
  63.  
  64.   # You probably want to change the name of the artifact ;-)
  65.   - task: PublishBuildArtifacts@1
  66.     displayName: 'Publish articats'
  67.     inputs:
  68.      ArtifactName: 'My precious'
  69.      PathtoPublish: '$(zip)'
Advertisement
Add Comment
Please, Sign In to add comment