This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 939
/
azure-pipelines.docker.yml
56 lines (49 loc) · 1.76 KB
/
azure-pipelines.docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Build Docker image for this app using Azure Pipelines
# http://docs.microsoft.com/azure/devops/pipelines/languages/docker?view=vsts
pool:
vmImage: 'Ubuntu 16.04'
variables:
imageName: 'pythonsample:$(Build.BuildId)'
# define two more variables dockerId and dockerPassword in the build pipeline in UI
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.5
architecture: 'x64'
- task: PythonScript@0
displayName: 'Export project path'
inputs:
scriptSource: 'inline'
script: |
"""Search all subdirectories for `manage.py`."""
from glob import iglob
from os import path
# Python >= 3.5
manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None)
if not manage_py:
raise SystemExit('Could not find a Django project')
project_location = path.dirname(path.abspath(manage_py))
print('Found Django project in', project_location)
print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location))
- script: |
python -m pip install --upgrade pip setuptools wheel django
pip install -r requirements.txt
pip install unittest-xml-reporting
displayName: 'Install prerequisites'
- script: |
pushd '$(projectRoot)'
python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
condition: succeededOrFailed()
displayName: 'Run tests'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: "**/TEST-*.xml"
testRunTitle: 'Python $(PYTHON_VERSION)'
- script: |
docker build -f Dockerfile -t $(dockerId)/$(imageName) .
docker login -u $(dockerId) -p $pswd
docker push $(dockerId)/$(imageName)
env:
pswd: $(dockerPassword)
displayName: 'Build and push Docker image'