I am running a YAML pipeline snapshot test using a new task I have published to marketplace and installed for our organizations.
- stage: stage
displayName: Stage
jobs:
- deployment: job
displayName: Job
environment: [Env name]
strategy:
canary:
deploy:
steps:
- bash: echo "Hello World"
- task: NuGetAuthenticate#0
- task: 1ESGPTRunTask#0.0.13
displayName: [Display Name]
continueOnError: false
inputs:
repoId: [repoId]
path: [scriptPath]
arguments: [arguments]
I included the first two steps as examples of steps/tasks that are passing successfully, but the last task is failing with the following exception:
"$id":"1","innerException":null,"message":"Invalid step task reference 1ESGPTRunTask#0.0.13","typeName":"Microsoft.Azure.Pipelines
.WebApi.PipelineValidationException, Microsoft.Azure.Pipelines.WebApi","typeKey":"PipelineValidationException","errorCode":0,"eventId"
:3000}
For more context, this task does run successfully for 50 other pipeline snapshot tests. It only fails on the three specifically related to deployment.
Related
I have two stages in my Azure DevOps pipeline. One with Pulumi Preview (let's call it Preview) and one with Pulumi Up (Up) in order to run my infrastructure as code.
Both run from the same container and it takes a while to pull it. I want to manually approve the Preview before the implementation.
Can I pull and run the container for both stages simultaneously but wait for the last job of the UP-Stage until the Preview-Stage is approved?
Currently they depend on eachother as follows:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Pulumi_Preview
jobs:
- job: Preview
container:
image: REGISTRY.azurecr.io/REPOSITORY:latest
endpoint: ServiceConnection
steps:
- task: Pulumi#1
displayName: pulumi preview
inputs:
azureSubscription: 'Something'
command: 'preview'
args: '--diff --show-config --show-reads --show-replacement-steps'
stack: $(pulumiStackShort)
cwd: "./"
- stage: Pulumi_Up
displayName: "Pulumi (Up)"
dependsOn: Pulumi_Preview
jobs:
- job: Up
container:
image: REGISTRY.azurecr.io/REPOSITORY:latest
endpoint: ServiceConnection
steps:
- task: Pulumi#1
inputs:
azureSubscription: 'Something'
command: 'up'
args: "--yes --skip-preview"
stack: $(pulumiStackShort)
cwd: "./"
You could use the Manual Validation Task.
Use this task in a YAML pipeline to pause a run within a stage, typically to perform some manual actions or validations, and then resume/reject the run.
jobs:
- job: waitForValidation
displayName: Wait for external validation
pool: server
timeoutInMinutes: 4320 # job times out in 3 days
steps:
- task: ManualValidation#0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
notifyUsers: |
test#test.com
example#example.com
instructions: 'Please validate the build configuration and resume'
onTimeout: 'resume'
I am working on having one yaml template file job dependOn a deployment job before continuing. I need my "other-template" job below to depend on the deployment job name "DeployApi"
# api-deploy.yml
jobs:
- deployment: DeployApi
...
release.yml
stages:
- stage: 'deploy_dev'
displayName: Deploy to dev environment
dependsOn: []
jobs:
- template: api/api-deploy.yml
parameters:
environment: ...
varTemplate: ...
- template: other/other-template.yml
parameters:
dependsOn: ['DeployApi']
Is it possible to have the second template "other/other-template.yml" depend on the "DeployApi" deployment job? I know it's possible if it was a standard job name but I couldn't find any information on if it's possible to use dependsOn for a deployment job name.
Little bit more information: I have about 10 release templates that run parallel (I believe). I have one release template that I want to wait to run until every other template is ran.
Yes, you can.
release.yml
trigger:
- none
pool:
vmImage: ubuntu-latest
stages:
- stage: 'deploy_dev'
displayName: Deploy to dev environment
dependsOn: []
jobs:
- template: api/api-deploy.yml
parameters:
environment: ...
varTemplate: ...
- template: other/other-template.yml
parameters:
dependsOn: ['DeployApi']
api/api-deploy.yml
jobs:
- job: DeployApi
steps:
- task: PowerShell#2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
Write-Host "This is api-deploy.yml."
other/other-template.yml
parameters:
dependsOn: []
jobs:
- job: getDependsOn
dependsOn: ${{parameters.dependsOn}}
steps:
- task: PowerShell#2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
Write-Host "This is other-template.yml"
Result successfully:
I have a gitlab pipeline which consiste of multiple stages[checkout->build->test->Deploy->cleanup->validation->terminate ec2].I have 3 requirement.
if any stage before the deploy stage failed, the pipeline stopped immediately.
if the deploy stage succeeds then the cleanup stage must skip and continue with another stage.
when only the deploy stage failed then only and must clean up stage run and exit the pipeline.
Here is my example pipeline.
stages:
- checkout
- build
- test
- Deploy
- cleanup
- reset
- Jenkins Jobs
- validation
checkout:
stage: checkout
tags:
- publishing
script:
- echo checkout
build:
stage: build
tags:
- automated-content-publishing
script:
- echo build
test:
stage: test
tags:
- publishing
script:
- echo test
Deploy:
stage: Deploy
tags:
- publishing
script:
- echo deploy
Cleanup:
stage: Cleanup
tags:
- publishing
script:
- echo clean-up
when: on_failure
reset:
stage: Nexus Insert
tags:
- publishing
script:
- echo reset
Jenksin Jobs:
stage: Jenkins Jobs
tags:
- publishing
script:
- echo jenkins jobs
vilidation:
stage: Vilidation
tags:
- publishing
script:
- echo validation
this pipeline works perfectly in 2 and 3 requirements. pipeline not working for 1 requirement. if any stage failed before the deploy stage failed cleanup stage call.
I want to call the cleanup stage only and only when the deploy stage failed.
Please guide me to build this case.
You could use something like this
Deploy:
stage: Deploy
tags:
- publishing
script:
- echo deploy
...
Cleanup:
stage: Cleanup
tags:
- publishing
script:
- echo clean-up
needs:
- job: Deploy
when: on_failure
If deploy stage has many jobs just add them to needs section. For more info look at reference.
The files in the related repo are available when running the Build stage of the Azure Dev Ops pipeline, but not when running the deploy stage. Any ideas as to why this would be the case?
Here is a simplified version of the yaml file:
# Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Name of the new namespace being created to deploy the PR changes.
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Bash#3
inputs:
targetType: 'inline'
script: |
pwd
ls -la
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
displayName: Deploy
pool:
vmImage: $(vmImageName)
environment: 'test.development'
strategy:
runOnce:
deploy:
steps:
- task: Bash#3
inputs:
targetType: 'inline'
script: |
pwd
ls -la
Additional notes:
If the deploy stage is run first (the build stage is removed) the working directory is also empty.
The job in your Deploy stage is a deployment job rather than a standard job, deployment jobs don't automatically checkout the repo that the pipeline is based on but they do have access to any published pipeline artifacts.
You can either publish a pipeline artifact in the Build stage or add a task to your Deploy stage to explicitly checkout the repo.
To publish a pipeline artifact add the Publish Pipeline Artifact as task in your Build stage. In your Deploy stage you can then reference files in that artifact with the path $(Pipeline.Workspace)/<artifactName>/<rest-of-path>
To checkout out the whole repo add this to your Deploy stage:
steps:
- checkout: self
path: 'myrepo/'
Then reference the files in the repo using $(System.DefaultWorkingDirectory)\<rest-of-path>
I have an Azure pipeline which needs to send a REST request to an endpoint. I am trying to use the built in task InvokeRESTAPI#1 to do this, but it errors when running on Azure DevOps.
Script:
---
trigger:
batch: true
branches:
include:
- master
pr:
- master
stages:
- stage: Run_Tests
jobs:
- job: RA001
pool: windows-server
steps:
- task: InvokeRESTAPI#1
displayName: "Run Test"
inputs:
connectionType: 'connectedServiceName'
serviceConnection: 'myconnection'
method: 'PUT'
headers: |
{
"AccessKey":"$(system.MyKey)"
}
urlSuffix: '/api/v3/schedules/uniquenumber/runNow'
waitForCompletion: 'false'
Returns:
Job RA001: Step references task 'InvokeRESTAPI' at version '1.152.1'
which is not valid for the given job target.
The InvokeRESTAPI#1 it's server job task (agentless job in the classic editor), not a regular task that can run on an agent.
You need to put it in server job in this way:
pool: server
More info you can find here.