Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d56d1c3
feat(test): generate downstream test pipeline only on PRs
Pythyu Dec 23, 2024
1e5b4c6
fix(gitlab): use needs
Pythyu Dec 23, 2024
a1784d9
fix(gitlab): use needs
Pythyu Dec 23, 2024
9ed9802
fix(gitlab): use needs
Pythyu Dec 23, 2024
d5479c6
fix(gitlab): use needs
Pythyu Dec 23, 2024
32ad0b4
fix(gitlab): use needs
Pythyu Dec 23, 2024
9a820e9
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
ce168e3
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
c524a2b
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
07a1f6e
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
aa69605
Merge branch 'master' into pythyu/downstream_pr_only
Pythyu Dec 24, 2024
bf2ee99
debug
Pythyu Dec 24, 2024
5824851
Merge branch 'pythyu/downstream_pr_only' of github.com:DataDog/omnibu…
Pythyu Dec 24, 2024
55cac40
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
6aa3aef
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
f2f4798
feat(dynamic): dyanmic pipeline based if on PR or not
Pythyu Dec 24, 2024
5d9d8ba
feat(dynamic): dynamic pipeline triggered also on master
Pythyu Dec 24, 2024
0f96a06
feat(dynamic): dynamic pipeline triggered also on master
Pythyu Dec 24, 2024
bc25978
revert(PR): only run on PRs
Pythyu Dec 24, 2024
5666d71
revert(PR): only run on PRs
Pythyu Dec 24, 2024
15098aa
revert(PR): only run on PRs
Pythyu Dec 24, 2024
06e0bfd
revert(PR): only run on PRs
Pythyu Dec 24, 2024
81ac262
revert(PR): only run on PRs
Pythyu Dec 24, 2024
2c032eb
revert(PR): only run on PRs
Pythyu Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .generated-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
stages:
- placeholder

# We need a placeholder success job because we can't trigger empty pipelines
# Can be replaced by a useful gitlab job to run on non-PR commits
success_job:
stage: placeholder
tags: ["arch:amd64"]
image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c
script:
- echo SUCCESS
103 changes: 103 additions & 0 deletions .gitlab-ci-agent-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
include: "https://gitlab-templates.ddbuild.io/slack-notifier/v3-sdm/template.yml"

stages:
- test
- after-test
- check-downstream
- notify

# We're using two anchors because Gitlab doesn't allow us to use multiple anchors inside of a rules field.
.skip_stable_branches: &skip_stable_branches
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH =~ /^7.[0-9]{2}.x/
when: never
- if: $CI_COMMIT_TAG != null
when: never
- changes:
- "**/*.rb"
- Rakefile
- omnibus-software.gemspec
- Gemfile
- .gitlab*
- .generated-pipeline.yml
- .gitlab-ci-agent-build.yml
when: always

.on_success_skip_stable_branches: &on_success_skip_stable_branches
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH =~ /^7.[0-9]{2}.x/
when: never
- if: $CI_COMMIT_TAG != null
when: never
- changes:
- "**/*.rb"
- Rakefile
- omnibus-software.gemspec
- Gemfile
- .gitlab*
- .generated-pipeline.yml
- .gitlab-ci-agent-build.yml
when: on_success

trigger-agent-build:
rules:
- *skip_stable_branches
- when: never
stage: test
trigger:
project: datadog/datadog-agent
strategy: depend
variables:
OMNIBUS_SOFTWARE_VERSION: $CI_COMMIT_BRANCH
RUN_ALL_BUILDS: "true"
RUN_KITCHEN_TESTS: "true"

on_success:
rules:
- *on_success_skip_stable_branches
- when: always
stage: after-test
needs:
- job: "trigger-agent-build"
optional: true
tags: ["arch:amd64"]
image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c
script:
- echo success > output.pipeline
artifacts:
paths:
- output.pipeline
expire_in: 1 week

# This job is monitored on github and acts as a required check.
# A few details on the setup:
# We can't monitor a trigger job from github, it has to have a script section.
# We need the monitored job to fail if the downstream pipeline failed, and succeed if
# the downstream pipeline succeeded. If the job is skipped, it isn't taken into account
# on github.
# This is where the on_success job kicks in. It run only if the previous job completes
# and writes `success` in a file that's fetched by the `check-downstream-pipeline` job.
# This allows us to have the check-downstream-pipeline to always run while replicating
# the status of the downstream pipeline.
check-downstream-pipeline:
rules:
- *skip_stable_branches
- when: always
stage: check-downstream
tags: ["arch:amd64"]
image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c
script:
- cat output.pipeline

notify:
extends: .slack-notifier-base
stage: notify
dependencies: []
rules:
- *skip_stable_branches
- when: never
script: |
export MESSAGE="Your omnibus-software test pipeline completed"
/usr/local/bin/notify.sh
118 changes: 29 additions & 89 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,37 @@
include: "https://gitlab-templates.ddbuild.io/slack-notifier/v3-sdm/template.yml"

stages:
- test
- after-test
- check-downstream
- notify

# We're using two anchors because Gitlab doesn't allow us to use multiple anchors inside of a rules field.
.skip_stable_branches: &skip_stable_branches
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH =~ /^7.[0-9]{2}.x/
when: never
- if: $CI_COMMIT_TAG != null
when: never
- changes:
- "**/*.rb"
- Rakefile
- omnibus-software.gemspec
- Gemfile
when: always
- generation
- trigger

.on_success_skip_stable_branches: &on_success_skip_stable_branches
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH =~ /^7.[0-9]{2}.x/
when: never
- if: $CI_COMMIT_TAG != null
when: never
- changes:
- "**/*.rb"
- Rakefile
- omnibus-software.gemspec
- Gemfile
when: on_success

trigger-agent-build:
rules:
- *skip_stable_branches
- when: never
stage: test
trigger:
project: datadog/datadog-agent
strategy: depend
variables:
OMNIBUS_SOFTWARE_VERSION: $CI_COMMIT_BRANCH
RUN_ALL_BUILDS: "true"
RUN_KITCHEN_TESTS: "true"

on_success:
rules:
- *on_success_skip_stable_branches
- when: always
stage: after-test
needs:
- job: "trigger-agent-build"
optional: true
check_if_branch_is_a_pr:
stage: generation
tags: ["arch:amd64"]
image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c
script:
- echo success > output.pipeline
allow_failure: true
script: |
cp .generated-pipeline.yml generated-pipeline.yml
# Check if our current branch is inside the PR list of omnibus-software
curl https://api.github.com/repos/DataDog/omnibus-software/pulls
if curl https://api.github.com/repos/DataDog/omnibus-software/pulls | grep "$CI_COMMIT_REF_NAME"
then
echo "Current commit is on a PR"
cp .gitlab-ci-agent-build.yml generated-pipeline.yml
else
echo "Current commit is not on a PR"
fi
artifacts:
untracked: true
expire_in: 1h
paths:
- output.pipeline
expire_in: 1 week
- generated-pipeline.yml

trigger_pipeline:
stage: trigger
needs:
- job: check_if_branch_is_a_pr
artifacts: true
trigger:
include:
- artifact: generated-pipeline.yml
job: check_if_branch_is_a_pr

# This job is monitored on github and acts as a required check.
# A few details on the setup:
# We can't monitor a trigger job from github, it has to have a script section.
# We need the monitored job to fail if the downstream pipeline failed, and succeed if
# the downstream pipeline succeeded. If the job is skipped, it isn't taken into account
# on github.
# This is where the on_success job kicks in. It run only if the previous job completes
# and writes `success` in a file that's fetched by the `check-downstream-pipeline` job.
# This allows us to have the check-downstream-pipeline to always run while replicating
# the status of the downstream pipeline.
check-downstream-pipeline:
rules:
- *skip_stable_branches
- when: always
stage: check-downstream
tags: ["arch:amd64"]
image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c
script:
- cat output.pipeline

notify:
extends: .slack-notifier-base
stage: notify
dependencies: []
rules:
- *skip_stable_branches
- when: never
script: |
export MESSAGE="Your omnibus-software test pipeline completed"
/usr/local/bin/notify.sh