You can configure the catalog job with when: never
, and then include the template in a job within the projects CI/CD config. Then, you can set rules accordingly.
It's late, so not providing an extremely stripped down version... real world examples are sometimes better anyway.
# netbird_install.yml
spec:
inputs:
stage:
default: test
netbird_registration_token:
description: \[DO NOT SET\] Registration token should be configured as CI/CD variable. Must be masked.
default: $NETBIRD_REGISTRATION_TOKEN
---
.netbird_install:
stage: $[[ inputs.stage ]]
when: never
script:
- |
apt-get update
apt-get install ca-certificates curl gnupg -y
curl -sSL https://pkgs.netbird.io/debian/public.key | gpg --dearmor --output /usr/share/keyrings/netbird-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/netbird-archive-keyring.gpg] https://pkgs.netbird.io/debian stable main' | tee /etc/apt/sources.list.d/netbird.list
apt update && apt install netbird iputils-ping -y
- netbird up --setup-key $[[ inputs.netbird_registration_token ]]
- ping -c 15 100.78.90.183
# .gitlab-ci.yml
stages:
- deploy
include:
- component: $CI_SERVER_FQDN/<my-group>/cicd-components/[email protected]
inputs:
stage: deploy
deploy_job_with_vpn:
stage: deploy
script:
- !reference [.netbird_install, script]
- echo "Getting netbird status:"
- netbird status
after_script:
- echo "Did the above work?"
when: always
Job output:
redacted environment prep
$ apt-get update # collapsed multi-line command
$ netbird up --setup-key $NETBIRD_REGISTRATION_TOKEN
Connected
$ ping -c 13 100.78.90.183
PING 100.78.90.183 (100.78.90.183) 56(84) bytes of data.
From 100.78.51.105 icmp_seq=3 Destination Host Unreachable
64 bytes from 100.78.90.183: icmp_seq=1 ttl=64 time=135 ms
64 bytes from 100.78.90.183: icmp_seq=2 ttl=64 time=168 ms
64 bytes from 100.78.90.183: icmp_seq=3 ttl=64 time=84.9 ms
--- 100.78.90.183 ping statistics ---
...
$ echo "Getting netbird status:"
Getting netbird status:
$ netbird status
OS: linux/amd64
Daemon version: 0.28.9
CLI version: 0.28.9
Management: Connected
Signal: Connected
Relays: 2/2 Available
Nameservers: 0/0 Available
FQDN: runner-<redacted>.netbird.cloud
NetBird IP: 100.78.51.105/16
Interface type: Kernel
Quantum resistance: false
Routes: -
Peers count: 1/2 Connected
Running after_script 00:00
Running after script...
$ echo "Did the above work?"
Did the above work?
Cleaning up project directory and file based variables 00:01
Job succeeded
Your initial post helped me, so hoping this returns the favor!