I want to create one yaml file which will build and release. Is this possible? I have a repo in Github and currently have a build yaml file in a pipeline. Currently there is a build pipeline separate and the release is then executed via Azure devops releases. I want to include both build and release in one yaml file but when i try to do this I cant seem to access files required from the build?
eg I have some terraform tf files in a directory on github which i need to execute terraform on. Despite terraform installing ok in the yaml file it cant find the tf files ? I thought the repo which includes the tf files gets copied to the build workstation but i cant see them there
CodePudding user response:
For is it possible to use one yaml file for build and release?
It is possible to do this. You can use the keyword of dependsOn
to continue to the next stage.
For example. we have two stages like Build and Release. You can follow the below example to use one yaml file for build and release.
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: YourBuildTask1
inputs:
...
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: ...
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: Release
dependsOn: Build
jobs:
- deployment: Deployment
variables:
- template: Template.yml
environment: Release
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Release Azure App Service'
inputs:
packageForLinux: '$(Pipeline.Workspace)/**/*.zip'
AppSettings: '-ASPNETCORE_ENVIRONMENT $(EnvironmentName) -ReleaseName $(Release.ReleaseName) -BuildId $(Build.BuildId)'
CodePudding user response:
is it possible to use one yaml file for build and release?
Short answer is Yes, I don't see any reason you shouldn't be able to do what you're wanting.
I thought the repo which includes the tf files gets copied to the build workstation but i cant see them there
I think we need more details about why you think that. Pipelines have various (hard to figure out) rules about what you have to do to "checkout" or pull various repos into your agent's working folder and where those repos get copied to, so we'd need to know more about what you're actually doing in your script, what your checkout steps are reporting, etc.