Scheduled run not running even though it was set up correctly? - azure-devops

I've added a schedule block to my pipeline that backs up my RDS database. This is the main yaml file for the pipeline, and yaml validator finds no errors. So why is it not running? Nothing shows up in Scheduled Runs section in the UI, and I actually waited 3 hours for it to run, to no avail. What am I missing?
name: $(Date:yyyyMMdd)$(Rev:.r)
variables:
- template: ../global-vars.yml
resources:
repositories:
- repository: self
type: git
name: Deployment
trigger: none
schedules:
- cron: "0 */3 * * *"
displayName: DB backup every 3 hours
branches:
include:
- master
always: true
stages:
- stage: DBBackup
displayName: DB Backup
jobs:
- template: /templates/db/backup.yml

There is no property schedules which can be placed in resources > repositories > repository according to YAML syntax documentation
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-repositories-repository?view=azure-pipelines
You can add schedules on the top level of YAML
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/schedules-cron?view=azure-pipelines
try something like this sample
name: $(Date:yyyyMMdd)$(Rev:.r)
variables:
- template: ../global-vars.yml
schedules:
- cron: "0 */3 * * *"
displayName: DB backup every 3 hours
branches:
include: master
always: true
resources:
repositories:
- repository: self
type: git
name: Deployment
trigger: none
stages: (...)

Related

Decrease the number of stages by making them into jobs

I tried to create the below yaml pipeline config file. Can I get some help on reducing the number of stages in YAML pipeline. This is to reduce number of stages per domain.
name: '$(Date:yyyy.MM.dd)$(Rev:.rr)'
trigger:
branches:
include:
- master
- features/*
pool:
name: CustomPool
stages:
- template: templates\build.yaml
- template: templates\deploy.yaml
parameters:
Environment: 'dev'
IsEnabled: true
Domain: 'domainX'
ServerList:
- name: ServerX
restartIIS: true
- template: templates\deploy.yaml
parameters:
Environment: 'test'
IsEnabled: true
Domain: 'domainY'
ServerList:
- name: ServerY
restartIIS: false
Scenario 1: If you don't want to use stages, you can only use jobs in the main YAML and your template. There is a demo you can refer to.
azure-pipelines.yml
trigger:
- none
pool:
vmImage: ubuntu-latest
jobs:
- template: JobTemplate1.yml
- template: JobTemplate2.yml
- template: JobTemplate3.yml
JobTemplate1.yml
jobs:
- job: job1_1
steps:
- script: echo This is job1_1
- job: job1_2
steps:
- script: echo This is job1_2
In this example, each template has 2 jobs. Eventually you can see a total of 6 jobs running.
Scenario 2: If you want to use stages in your main YAML but just want to decrease the stages in your template, you can use only one stage and several jobs in your template.
azure-pipelines.yml
trigger:
- none
pool:
vmImage: ubuntu-latest
stages:
- template: template1.yml
- template: template2.yml
- template: template3.yml
template1.yml
stages:
- stage: Template1_Stage
jobs:
- job: Template1_Stage_job1
steps:
- script: echo This is Template1_Stage_job1
- job: Template1_Stage_job2
steps:
- script: echo This is Template1_Stage_job2
In this example, template1 has one stage and two jobs. Template2 has two stages, and each stage has one job. Template3 has one stage and one job. For your case, you can refer to template1.

Scheduled Github action does not start

my cron jobs seems not to work. The file does not contain errors and works correctly in the push phase; however if I schedule the cron every 5 minutes, it never starts:
name: Deploy to Cloud Foundry Scheduled
on:
push:
branches: [ 'master' ]
pull_request:
schedule:
- cron: '*/5 * * * *'
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
# my steps here
Can you help me understand what I'm doing wrong?

Sequentially launch of builds of multiple projects in Gitlab CI/CD

I have one project (parent) that triggers a number of child projects (child_1, child_2) I can build parallel, and one (sub_child) more I need to build after successfully completing the previous child builds.
I made follow ci scripts:
parent
variables:
FLAGGER_REBUILD: "true"
COMMON_ONLY: "true"
stages:
- build_parent
- build_child
- build_sub_child
build parent:
stage: build_parent
retry: 2
when: on_success
only:
- master
script:
- echo "PARENT"
- date
.sub_build_template: &build_conf
stage: build_child
when: on_success
only:
refs:
- master
variables:
- $COMMON_ONLY == "true"
rebuild child_1:
<<: *build_conf
trigger:
project: ci_test/child_1
rebuild child_2:
<<: *build_conf
trigger:
project: ci_test/child_2
rebuild sub_child:
stage: build_sub_child
when: on_success
only:
refs:
- master
variables:
- $COMMON_ONLY == "true"
trigger:
project: ci_test/sub_child
child_1, 2
variables:
FLAGGER_REBUILD: "false"
stages:
- build_child_1
- build_sub_child
build image:
stage: build_child_1
retry: 2
when: on_success
only:
- master
script:
- echo "CHILD 1"
- date
rebuild flagger:
stage: build_sub_child
when: on_success
only:
refs:
- master
variables:
- $FLAGGER_REBUILD == "true"
trigger:
project: ci_test/sub_child
sub_child
variables:
FLAGGER_REBUILD: "false"
stages:
- build_sub_child
build flagger:
stage: build_sub_child
retry: 2
when: on_success
script:
- echo "SUB CHILD"
- date
Gitlab made the following scheme of launching:
img_1
But all children and sub_child tasks launch at one time. It's not good.
So, how do I need to change parent, children, or sub_child scripts to gen correct launching of builds?
img_2
img_3
I use Gitlab version 11.10.8-ee and I am not allowed to upgrade the version at the moment. Please help me decide on this task.
Thank you.

Azure Devops Pipeline Scheduled trigger on other repository

I have a repo with Yaml definition of pipelines, that reference other repo for steps.
I'm trying to have the pipeline triggered based on a scheduled (cron) definition (only when source code changed) of a repo that is not the repo of the pipeline.
I tried that but the pipeline is not triggered:
resources:
repositories:
- repository: self
type: git
ref: master
- repository: my-project
name: my-project
type: git
ref: master
schedules:
- cron: 55 10 * * 1,2,3,4,5
branches:
include:
- master
always: false
trigger: none
pr: none
(...)
Repository "self" references the repo with pipeline YAML file(s)
If I get rid of the last two lines, the pipeline is triggered when I save it, but not when I change code on "my-project"
I tried also with ref/heads prefixes for branch name without any change.
Any idea?
This can't be done, the way you're trying. A repository resource can include a trigger, but not a schedule; see the docs at https://learn.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=schema#define-a-repositories-resource
What you can do is a non-scheduled trigger:
resources:
repositories:
- repository: self
type: git
ref: master
- repository: my-project
name: my-project
type: git
ref: master
trigger:
branches:
include:
- master
This won't work on any schedule; it will simply be immediately triggered by any change to the code in my-project, in the master branch.

Azure Devops pipeline can't find a checkouted template

My issue
I have an Azure devops project with a template on another repository than main one's.
I try to load the template but I get this:
/azure-pipelines.yml: File /TemplateRepository/build.yml not found in
repository
https://dev.azure.com/XXXXX/TestAzureDevops/_git/TemplateRepository
branch refs/heads/main
What I did
build.yml is my template into repository: TemplateRepository.
azure-pipelines.yml is my main file.
this is my template:
parameters:
- name: 'name'
default: 'name'
type: 'string'
steps:
- script: echo ${{parameters.name}}
This is my main:
pool:
vmimage: 'windows-latest'
parameters:
- name: contexts
type: object
default: [{
name: macOS,
pool: 'macOS-latest',
sign: false
},
{
name: Windows,
pool: 'windows-latest',
sign: true
}]
resources:
repositories:
- repository: Tuto-Ressources
ref: main
type: git
name: TemplateRepository
stages:
- stage: BUILD
jobs:
- job: test
steps:
- checkout: self
- checkout: Tuto-Ressources
- script: dir
displayName: Dir
- ${{ each context in parameters.contexts }}:
- template: .\TemplateRepository\build.yml#Tuto-Ressources
parameters:
name: ${{context.name}}
pool: ${{context.pool}}
sign: ${{context.sign}}
buildSteps:
- checkout: self
- checkout: Tuto-Ressources
- bash: echo "Test module"
What I tested
If I remove the template lines from main script so I just have script: dir I can see my checkout on the VM and build.yml into \TemplateRepository directory.
So there is no reason it can't find my template.
I checked the branch name, it's main and I have no other one. I can see the file from the Devops Portal
What I need
I would like to understand what happen and what I can do.
I know there are artifact, but in this situation I don't understand whay it is not working like this because I don't change job neither stage.
The template line should reference the template file by its path relative to TemplateRepository. If your build template resides at \build.yml in TemplateRepository, then you should just do:
- template: build.yml#Tuto-Ressources
Also, you don't need to do - checkout: Tuto-Ressources - the pipeline engine will know to fetch the template file from referenced repository.