solomem / DevOps

0 stars 0 forks source link

ADO templates YAML #2

Open solomem opened 1 year ago

solomem commented 1 year ago

Docker Installer task

- task: DockerInstaller@0
  displayName: Docker Installer
  inputs:
    dockerVersion: 17.09.0-ce
    releaseType: stable

(build) Docker

trigger:
 - main

 pool:
   vmImage: 'ubuntu-latest' 

 variables:
   imageName: 'pipelines-javascript-docker'

 steps:
 - task: Docker@2
   displayName: Build an image
   inputs:
     repository: $(imageName)
     command: build
     Dockerfile: app/Dockerfile
solomem commented 1 year ago

Predefined variables:

This is the same variable that is specified by default in the Publish task (the --output argument), as well as in other tasks. $(Build.ArtifactStagingDirectory) : BUILD_ARTIFACTSTAGINGDIRECTORY

build

$(build.SourceBranchName)

$(build.DefinitionName)

$(build.artifactstagingdirectory) # where the artifacts are pushed to

system

$(System.DefaultWorkingDirectory) # where source code are downloaded to

solomem commented 1 year ago

Cloudformation Create/Update Stack task

solomem commented 1 year ago

set variables in bash

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash

solomem commented 1 year ago

ADO Agent folder structure

https://stackoverflow.com/questions/63117797/azure-pipelines-is-there-a-way-to-view-the-folder-structure

echo "Structure of work folder of this pipeline:"
tree $(Agent.WorkFolder)\1 /f

echo "Build.ArtifactStagingDirectory:" 

echo "$(Build.ArtifactStagingDirectory)"

echo "Build.BinariesDirectory:" 

echo "$(Build.BinariesDirectory)"

echo "Build.SourcesDirectory:"

echo "$(Build.SourcesDirectory)"

$(Agent.WorkFolder) represents the working folder for current agent,

$(Agent.WorkFolder)\1 represents the working folder for current pipeline. (Normally the first pipeline will be put in $(Agent.WorkFolder)\1, and the second $(Agent.WorkFolder)\2...)

So it's obvious that for one pipeline run, it has four folders by default: a (artifact folder), b (binaries folder), s (source folder) and TestResults (Test results folder).

The s folder is where the source code files are downloaded. For build pipeline: $(Build.SourcesDirectory), $(Build.Repository.LocalPath) and $(System.DefaultWorkingDirectory) represent the same folder.

image

More details see predefined variables.

solomem commented 1 year ago

image