是否有任何方法在我的本地机器上运行Azure DevOps管道yaml文件?



据我所知,实际上,我不知道'如何运行(不验证))本地的Azure DevOps yaml文件'.

我正在寻找一个YAML管道AzureDevops到Dockerfile多阶段转换器以便自动生成准备在本地测试管道的Dockerfile

让我们保留这个Azure DevOps多级yaml文件,你可以在microsoft GitHub上找到它

# Python to Linux Web App on Azure
# Build your Python project and deploy it to Azure as a Linux Web App.
# Change python version to one thats appropriate for your application.
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger:
- {{ branch }}
variables:
# Azure Resource Manager connection created during pipeline creation
azureServiceConnectionId: '{{ azureServiceConnection.Id }}'
# Web app name
webAppName: '{{ webAppName }}'
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Environment name
environmentName: '{{ webAppName }}'
# Project root folder. Point to the folder containing manage.py file.
projectRoot: $(System.DefaultWorkingDirectory)
# Python version: 3.7
pythonVersion: '3.7'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: BuildJob
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python $(pythonVersion)'
- script: |
python -m venv antenv
source antenv/bin/activate
python -m pip install --upgrade pip
pip install setup
pip install -r requirements.txt
workingDirectory: $(projectRoot)
displayName: "Install requirements"
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(projectRoot)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
displayName: 'Upload package'
artifact: drop
- stage: Deploy
displayName: 'Deploy Web App'
dependsOn: Build
condition: succeeded()
jobs:
- deployment: DeploymentJob
pool:
vmImage: $(vmImageName)
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
displayName: 'Use Python version'
- task: AzureWebApp@1
displayName: 'Deploy Azure Web App : {{ webAppName }}'
inputs:
azureSubscription: $(azureServiceConnectionId)
appName: $(webAppName)
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip

我正在手动(这很麻烦)将我的yaml文件转换为多阶段的Dockerfiles,如下所示,(与上面提到的复杂的yaml文件无关)为了在本地使用multi-stage building测试我的yaml文件,您可以在这里找到官方Docker文档(下面修改了一点)

FROM alpine:latest AS builder
COPY source.cpp source.cpp
COPY source-with-unittest.cpp source-with-unittest.cpp
RUN apk --no-cache add build-base
FROM builder AS build
RUN g++ -o /binary source.cpp
FROM builder AS test
RUN g++ -o /binary-with-unittest source-with-unittest.cpp
预期

<转换工具/strong>

./convert --azure-pipeline-definition azure-pipeline.yaml --dockerfile-name Multistaged-Dockerfile
..
..
..
SUCCESSFULLY COMPLETED
"azure-pipeline.yaml" is converted into a multistaged dockerfile named: "Multistaged-Dockerfile"!
Test your pipeline locally running the following command
> docker build --tag <IMAGENAME:TAG> --file Multistaged-Dockerfile

使用Dockerfile本地测试管道

docker build --tag testpipeline:locally --file Multistaged-Dockerfile

通常被模拟AzureDevOps远程管道在我的本地机器上执行。


的原因
  • 包含azure开发定价
  • 在关键天减少队列azure devops代理负载

尝试使用Azure DevOps门户,其中有一个内置验证特性的选项。当您创建或修改YAML管道时,Azure DevOps将自动验证文件的语法并突出显示任何错误或警告。

相关内容

  • 没有找到相关文章

最新更新