Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects

Prepare to run manually, CI form.

Merged Diego MENDEZ requested to merge feature/ci_form into main
1 file
+ 47
2
Compare changes
  • Side-by-side
  • Inline
+ 47
2
############################################################################
# This job needs a CI file with the name "NETBOX_LIST". JSON Format. e.g.:
# ```
# [
# {
# "netbox": "http://netbox.domain.com:8080",
# "token": "somenetboxtoken123456789",
# "description": "optinal_description_value"
# },
# {
# "netbox": "http://netbox.domain2.com:8082",
# "token": "somenetboxtoken123456789",
# "description": "testing_lab2"
# }
# ]
# ```
############################################################################
variables:
COMMIT_TAG:
value: $CI_COMMIT_TAG
options:
- $CI_COMMIT_TAG
- "test-deploy"
description: "Select tag 'test-deploy' to upload image to a Netbox. Make sure tag do not exists already on target."
NETBOX_URL:
value: "http://netbox.domain2.com:8080"
description: "Your target Netbox."
NETBOX_TOKEN:
value: "yourtestingtoken123456789"
description: "Token of your target Netbox."
.default_deploy_rules:
rules:
# if manually triggered from CI forms
- if: $COMMIT_TAG == "test-deploy"
when: on_success
# if not main branch
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
when: never
# if tagged
- if: $CI_COMMIT_TAG
when: on_success
@@ -11,7 +48,6 @@ deploy-job:
REGISTRY: https://code.europa.eu:4567/v2/
REGISTRY_IMAGE_NETBOX: code.europa.eu:4567/digit-c4/netbox-plugins
REGISTRY_IMAGE: $CI_REGISTRY_IMAGE
COMMIT_TAG: $CI_COMMIT_TAG
before_script:
# print variables
- echo $REGISTRY_IMAGE
@@ -19,10 +55,19 @@ deploy-job:
# requirements
- mkdir -p "$CI_PROJECT_DIR/opt_tmp/"
- sudo apt install jq -y
# decide list of netbox to target
- |
if [[ $COMMIT_TAG == "test-deploy" ]] ; then
# if running manually, then just prepare values from CI form.
echo '[{ "netbox": "'${NETBOX_URL%%[[:space:]]*}'", "token": "'${NETBOX_TOKEN%%[[:space:]]*}'" }]' > "$CI_PROJECT_DIR/opt_tmp/list.json"
else
# else, prepare full list of Netbox.
cat $NETBOX_LIST > "$CI_PROJECT_DIR/opt_tmp/list.json"
fi
script:
- |
# iterate over netbox's urls
for str1 in $(cat $NETBOX_LIST | jq -c '.[]')
for str1 in $(cat "$CI_PROJECT_DIR/opt_tmp/list.json" | jq -c '.[]')
do
# declare variables
NETBOX_URL=$(echo ${str1} | jq -r '.netbox')
Loading