Home > database >  Run only one build pipeline task on a schedule
Run only one build pipeline task on a schedule

Time:01-24

Is it possible to run only one build pipeline task on a schedule and not the whole pipeline on a schedule? I have a task in a build pipeline to generate some report about the pipeline. I would want the task to run once every month.

CodePudding user response:

Put the task in a second pipeline, and run that on a monthly schedule.

If you want to avoid yaml code duplication, you could define a template containing that one task and have that template called from both pipelines.

CodePudding user response:

Yes.. it is possible in several ways:

  • you can set previously to the task the condition:

     ${{ if eq(variables['isBuild'], true) }}:
    
  • You can configure conditions to run the tasks that you want, depending of whatever, for example in this case using the variable isBuild, defined previously:

     task: PublishBuildArtifacts@1
        displayName: 'Publish artifact: drop'
        inputs:
          PathtoPublish: 'whatever'
          ArtifactName: 'drop'
          publishLocation: 'Container'
        condition: eq(variables['isBuild'], true)
    
  • You can configure conditions to run the stages that you want, so previously you can group your tasks in stages, depending of whatever, for example using in this case in stage the variable isBuild, defined previously:

    stage: Build   
    displayName: 'Build'   
    condition: eq(variables['isBuild'], true)
    

In every example in case of IsBuild be different to true will not be run.

You can find more info in https://github.com/MicrosoftDocs/azure-devops-docs/blob/main/docs/pipelines/process/conditions.md

  •  Tags:  
  • Related