Compare commits
62 Commits
Author | SHA1 | Date | |
---|---|---|---|
6694986367 | |||
224ef83157 | |||
034a153ba0 | |||
6f8dfcba0b | |||
58ffcabbfb | |||
673441f83a | |||
b9f65bf908 | |||
02422c55b8 | |||
e9b5925be3 | |||
a24f352ca3 | |||
9492699abd | |||
9afa68d1f3 | |||
bd5c300d9d | |||
582fa67ea5 | |||
41eeb7badd | |||
6f80ea3af7 | |||
4f65bc1367 | |||
8094694d43 | |||
f987f9e4f0 | |||
b329eedd00 | |||
34c81c9849 | |||
8265977c7f | |||
d30abfdb73 | |||
c7c966bbee | |||
e6ba068b68 | |||
74ac15925c | |||
21db41bae1 | |||
e046f9ea49 | |||
4a0fa49b3f | |||
03609e2c9d | |||
d29064f149 | |||
6bcd588da8 | |||
5eb34f87e5 | |||
fe1fc844d5 | |||
d77fefd095 | |||
d4c534b95a | |||
9841eebb9d | |||
c05c421425 | |||
be612d905c | |||
1d67a0aa45 | |||
1716032215 | |||
82e7be6849 | |||
dee50b4ba0 | |||
5d333e994f | |||
64f08b5d3d | |||
4b6c0ac9f7 | |||
80a9e7f183 | |||
02252db664 | |||
8f25d1a09e | |||
bea398200f | |||
e1a7f60401 | |||
9b57371358 | |||
fc9f37617c | |||
3fa71fe91a | |||
6700cdbc90 | |||
955ce37520 | |||
3fbd4317c0 | |||
c4087c7069 | |||
bd22ff566c | |||
0f6e06c50f | |||
67199ccc55 | |||
b8199586b4 |
2
.cz.yaml
2
.cz.yaml
@ -4,4 +4,4 @@ commitizen:
|
||||
name: cz_conventional_commits
|
||||
tag_format: $major.$minor.$patch$prerelease
|
||||
update_changelog_on_bump: true
|
||||
version: 0.6.1
|
||||
version: 0.7.0rc0
|
||||
|
102
.gitlab-ci.yml
102
.gitlab-ci.yml
@ -19,6 +19,8 @@ include:
|
||||
- local: $JOB_ROOT_DIR/gitlab_release/.gitlab-ci.yml
|
||||
- local: $JOB_ROOT_DIR/lint/markdown.gitlab-ci.yaml
|
||||
- local: $JOB_ROOT_DIR/python/.gitlab-ci.yml
|
||||
# - local: $JOB_ROOT_DIR/test/.gitlab-ci.yml
|
||||
- local: $JOB_ROOT_DIR/ansible/collection/ci-test.gitlab-ci.yml
|
||||
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
||||
#- template: Security/License-Scanning.gitlab-ci.yml
|
||||
|
||||
@ -119,79 +121,29 @@ gilab-ci.yml Lint (python 3.11):
|
||||
image: python:3.11-slim
|
||||
|
||||
|
||||
Ansible_docker_os.Submodule.Deploy:
|
||||
Update Sub Repo:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_docker_os
|
||||
|
||||
|
||||
Ansible_playbooks.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_playbooks
|
||||
|
||||
|
||||
Ansible-roles.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible-roles
|
||||
|
||||
|
||||
config.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/config
|
||||
|
||||
|
||||
Docker_Mail.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-mail
|
||||
|
||||
|
||||
docker-buildx-qemu.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-buildx-qemu
|
||||
|
||||
|
||||
docker-glpi.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-glpi
|
||||
|
||||
|
||||
docker_management.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/docker_management
|
||||
|
||||
|
||||
execution_environment.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/execution_environment
|
||||
|
||||
|
||||
git_configuration.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/git_configuration
|
||||
|
||||
|
||||
nodered_ldap_self_service.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/nodered_ldap_self_service
|
||||
|
||||
|
||||
Ops.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/ops
|
||||
|
||||
|
||||
Website.Submodule.Deploy:
|
||||
extends: .submodule_update_trigger
|
||||
variables:
|
||||
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website
|
||||
parallel:
|
||||
matrix:
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/ops
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/configuration-management/itil_runbooks
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_playbooks
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible-roles
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_docker_os
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/ansible_test
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/ci-test
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/firewall
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/kubernetes
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/collections/phpipam_scan_agent
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/common
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/docker_management
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/execution_environment
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/git_configuration
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/homeassistant
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/nfc_glpi
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-bind
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-mail
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-buildx-qemu
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-glpi
|
||||
- SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/kubernetes_monitoring
|
||||
|
9
.vscode/extensions.json
vendored
Normal file
9
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"gitlab.gitlab-workflow",
|
||||
"jebbs.markdown-extended",
|
||||
"redhat.vscode-yaml",
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"streetsidesoftware.code-spell-checker-australian-english"
|
||||
]
|
||||
}
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"gitlab.aiAssistedCodeSuggestions.enabled": false,
|
||||
"gitlab.duoChat.enabled": false,
|
||||
"cSpell.language": "en-AU,en"
|
||||
}
|
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,3 +1,21 @@
|
||||
## 0.7.0rc0 (2024-02-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **mkdocs**: [3fa71fe9](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3fa71fe91ad1e874b76fab7323e02496ac757f5d) - correct mkdocs image name [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) ]
|
||||
- **commit_footer_refs**: [0f6e06c5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/0f6e06c50f7cae602cdc2ca00bbce7fe1fd72c32) - enable automated jobs without MR to succeed. [ [#44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/44) [!72](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/72) ]
|
||||
- **commit_footer_refs**: [b8199586](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/b8199586b4fe4c9f93efe68a908eaa8582f064c3) - dont update git submodules [ [!71](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/71) [#42](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/42) [!2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/2) ]
|
||||
|
||||
### Code Refactor
|
||||
|
||||
- **mkdocs**: [955ce375](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/955ce3752050e78085c2037fe66714db41114c9e) - set env name to gitlab pages [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) [#43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/43) ]
|
||||
|
||||
### Features
|
||||
|
||||
- **sub_module_update**: [fc9f3761](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/fc9f37617cd26b3e44326161ba10183eb13444dd) - wbsite-template [ [!44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/44) ]
|
||||
- **mkdocs**: [3fbd4317](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3fbd4317c0388fb8e406eb78614e3943375496ed) - update requirements.txt to current versions [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) [!13](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/13) [!44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/44) ]
|
||||
- **mkdocs**: [c4087c70](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/c4087c7069524df573a43db29c399940600ddba7) - update python to 3.11.2 [ [!73](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/73) [!13](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/13) [!44](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/44) ]
|
||||
|
||||
## 0.6.1 (2023-11-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
662
ansible/collection/.gitlab-ci.yml
Normal file
662
ansible/collection/.gitlab-ci.yml
Normal file
@ -0,0 +1,662 @@
|
||||
---
|
||||
|
||||
variables:
|
||||
ANSIBLE_GALAXY_UPLOAD_TOKEN: "" # Mandatory, String. The token to upload to ansible galaxy. DONT SET HERE, USE PIPELINE VARIABLES.
|
||||
ANSIBLE_GALAXY_SERVER_URL: https://galaxy.ansible.com # Optional, default=(as displayed)String. URL to the Galaxy server for uploads
|
||||
ANSIBLE_GALAXY_NAMESPACE: "" # Mandatory, String. The ansible galaxy upload namespace
|
||||
ANSIBLE_GALAXY_PACKAGE_NAME: "" # Mandatory, String. The Ansible Galaxy package name
|
||||
|
||||
|
||||
.ansible_collection_merge:
|
||||
stage: chores
|
||||
image: python:3.11-bookworm
|
||||
before_script:
|
||||
- | # Create artifact directory
|
||||
mkdir -p artifacts
|
||||
|
||||
- | # Install Pre-req packages
|
||||
apt update;
|
||||
|
||||
apt install -y --no-install-recommends \
|
||||
curl \
|
||||
git;
|
||||
|
||||
# ToDo: Install python deps
|
||||
- |
|
||||
pip install \
|
||||
commitizen==3.14.1
|
||||
|
||||
- | # setup git user
|
||||
git config --global user.email "helpdesk@nofusscomputing.com";
|
||||
git config --global user.name "nfc_bot";
|
||||
|
||||
- | # Update origin using gitlab token
|
||||
echo "Current git origin";
|
||||
|
||||
git remote -v;
|
||||
|
||||
git remote remove origin;
|
||||
|
||||
echo "Removed origin";
|
||||
|
||||
git remote add origin https://gitlab-ci-token:$GIT_COMMIT_TOKEN@gitlab.com/$CI_PROJECT_PATH.git;
|
||||
|
||||
echo "Add origin with auth";
|
||||
|
||||
git remote -v;
|
||||
|
||||
- | # fetch repo details
|
||||
git fetch -fpv;
|
||||
|
||||
- | # switch to dev branch
|
||||
git switch development;
|
||||
|
||||
- | # pull dev branch
|
||||
git pull origin development --rebase
|
||||
|
||||
- | # Init git sub-modules
|
||||
git submodule update --init
|
||||
|
||||
|
||||
script:
|
||||
|
||||
|
||||
- | # Store old version number
|
||||
export OLD_VERSION=$(cz version --project);
|
||||
echo "Trace - OLD_VERSION[$OLD_VERSION]"
|
||||
|
||||
# rc codes https://commitizen-tools.github.io/commitizen/exit_codes/
|
||||
- | # Bump the version
|
||||
|
||||
if [ "0${VERSION_BUMP_INCREMENT}" != '0' ]; then
|
||||
|
||||
export BUMP_INCREMENT="--increment ${VERSION_BUMP_INCREMENT}";
|
||||
|
||||
fi;
|
||||
|
||||
if [ $CI_COMMIT_BRANCH == "development" ]; then
|
||||
|
||||
cz bump \
|
||||
--files-only \
|
||||
--yes \
|
||||
${BUMP_INCREMENT} \
|
||||
--prerelease alpha \
|
||||
|
||||
|
||||
export VERSION_BUMPED=$?
|
||||
|
||||
elif [ $CI_COMMIT_BRANCH == "master" ]; then
|
||||
|
||||
cz bump \
|
||||
--files-only \
|
||||
${BUMP_INCREMENT} \
|
||||
--yes
|
||||
|
||||
export VERSION_BUMPED=$?
|
||||
|
||||
else
|
||||
|
||||
echo "Something went wrong with creating the release";
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
echo "Trace - VERSION_BUMPED[$VERSION_BUMPED]"
|
||||
|
||||
- | # Store new version number
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
export NEW_VERSION=$(cz version --project)
|
||||
|
||||
echo "Trace - NEW_VERSION[$NEW_VERSION]"
|
||||
|
||||
fi;
|
||||
|
||||
- | # git stage .cz.yaml
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git add .cz.yaml;
|
||||
|
||||
echo "git staged .cz.yaml";
|
||||
|
||||
git status;
|
||||
|
||||
fi;
|
||||
|
||||
- | # Update version in galaxy file
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
sed -E "s/version: (.+)/version: ${NEW_VERSION}/g" -i galaxy.yml
|
||||
|
||||
fi;
|
||||
|
||||
- | # git stage galaxy.yml
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git add galaxy.yml
|
||||
|
||||
echo "git staged galaxy.yml";
|
||||
|
||||
git status;
|
||||
|
||||
fi;
|
||||
|
||||
- | # changelog since last version - for development branch
|
||||
echo "changelog since last version - for development branch";
|
||||
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
cz changelog --incremental --dry-run --unreleased-version "${NEW_VERSION}" > artifacts/incremental_changelog.txt
|
||||
|
||||
ls -lR artifacts/
|
||||
|
||||
fi;
|
||||
|
||||
- | # store incremental changelog since last version
|
||||
echo "store incremental changelog since last version";
|
||||
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
curl \
|
||||
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
--upload-file artifacts/incremental_changelog.txt \
|
||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/incremental_changelog.txt"
|
||||
|
||||
fi;
|
||||
|
||||
- | # complete changelog since last normal release - for master branch
|
||||
echo "complete changelog since last normal release - for master branch";
|
||||
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
cz changelog --merge-prerelease --dry-run --unreleased-version "${NEW_VERSION}" > artifacts/full_changelog.txt
|
||||
|
||||
fi;
|
||||
|
||||
- | # store full changelog (merge-prerelease)
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
curl \
|
||||
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
--upload-file artifacts/full_changelog.txt \
|
||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/full_changelog.txt"
|
||||
|
||||
fi;
|
||||
|
||||
- | # Update CHANGELOG.md
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
if [ $CI_COMMIT_BRANCH == "development" ]; then
|
||||
|
||||
cz changelog --incremental --unreleased-version "${NEW_VERSION}";
|
||||
|
||||
elif [ $CI_COMMIT_BRANCH == "master" ]; then
|
||||
|
||||
cz changelog --merge-prerelease --unreleased-version "${NEW_VERSION}";
|
||||
|
||||
else
|
||||
|
||||
echo "This job should only run on 'development' and 'master' branches";
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
fi;
|
||||
|
||||
- | # Create release notes
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
if [ $CI_COMMIT_BRANCH == "development" ]; then
|
||||
|
||||
cp artifacts/incremental_changelog.txt artifacts/release_notes.md
|
||||
|
||||
elif [ $CI_COMMIT_BRANCH == "master" ]; then
|
||||
|
||||
cp artifacts/full_changelog.txt artifacts/release_notes.md
|
||||
|
||||
else
|
||||
|
||||
echo "This job should only run on 'development' and 'master' branches";
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
fi;
|
||||
|
||||
- | # Store Release notes
|
||||
curl \
|
||||
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
--upload-file artifacts/release_notes.md \
|
||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/release_notes.md";
|
||||
|
||||
- | # git stage CHANGELOG.md
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git add CHANGELOG.md;
|
||||
|
||||
echo "git staged CHANGELOG.md";
|
||||
|
||||
git status;
|
||||
|
||||
fi;
|
||||
|
||||
- | # Custom commands from RELEASE_ADDITIONAL_ACTIONS_BUMP
|
||||
if [ -f ${RELEASE_ADDITIONAL_ACTIONS_BUMP} ]; then
|
||||
|
||||
echo "Custom commands found in variable RELEASE_ADDITIONAL_ACTIONS_BUMP";
|
||||
|
||||
chmod +x ${RELEASE_ADDITIONAL_ACTIONS_BUMP};
|
||||
|
||||
echo '------------------------------ TRACE SoF ------------------------------';
|
||||
|
||||
echo "File: RELEASE_ADDITIONAL_ACTIONS_BUMP[${RELEASE_ADDITIONAL_ACTIONS_BUMP}]";
|
||||
|
||||
echo '------ contents ------';
|
||||
|
||||
echo "";
|
||||
|
||||
cat ${RELEASE_ADDITIONAL_ACTIONS_BUMP};
|
||||
|
||||
echo "";
|
||||
|
||||
echo '------ contents ------';
|
||||
|
||||
echo "";
|
||||
|
||||
${RELEASE_ADDITIONAL_ACTIONS_BUMP};
|
||||
|
||||
echo "";
|
||||
|
||||
echo "git reset edited file: ${RELEASE_ADDITIONAL_ACTIONS_BUMP}";
|
||||
|
||||
git restore ${RELEASE_ADDITIONAL_ACTIONS_BUMP};
|
||||
|
||||
git status
|
||||
|
||||
echo '------------------------------ TRACE EoF ------------------------------'
|
||||
fi;
|
||||
|
||||
# - | # Find merge request ID
|
||||
# echo "Trace CI_OPEN_MERGE_REQUESTS[${CI_OPEN_MERGE_REQUESTS}]";
|
||||
|
||||
# if grep -q "," <<< "$CI_OPEN_MERGE_REQUESTS"; then
|
||||
|
||||
# export MERGE_REQUEST_FOUND=$(echo "${CI_OPEN_MERGE_REQUESTS}" | cut -d "," -f 1 | cut -d '!' -f 2);
|
||||
|
||||
# else
|
||||
|
||||
# export MERGE_REQUEST_FOUND=$(echo "${CI_OPEN_MERGE_REQUESTS}" | cut -d '!' -f 2);
|
||||
|
||||
# fi
|
||||
|
||||
# echo "Trace MERGE_REQUEST_FOUND[${MERGE_REQUEST_FOUND}]";
|
||||
|
||||
# if [ "$CI_MERGE_REQUEST_IID" ]; then
|
||||
|
||||
# export MERGE_REQUEST_FOUND=${CI_MERGE_REQUEST_IID}
|
||||
|
||||
# echo "Using CI_MERGE_REQUEST_IID[${CI_MERGE_REQUEST_IID}] as value for MERGE_REQUEST_FOUND";
|
||||
|
||||
# fi
|
||||
|
||||
- | # Find merge request ID
|
||||
echo "Trace CI_OPEN_MERGE_REQUESTS[${CI_OPEN_MERGE_REQUESTS}]";
|
||||
|
||||
echo "Trace CI_MERGE_REQUEST_IID[${CI_MERGE_REQUEST_IID}]";
|
||||
|
||||
export MERGE_REQUEST_FOUND=$(git log -1 | grep -E '\!(.+)' | cut -d '!' -f 2);
|
||||
|
||||
echo "Trace MERGE_REQUEST_FOUND[${MERGE_REQUEST_FOUND}]";
|
||||
|
||||
- | # commit any changes
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git status;
|
||||
|
||||
echo "commit changes to repo"
|
||||
|
||||
cat <<EOF | git commit -F-
|
||||
build: bump version ${OLD_VERSION} -> ${NEW_VERSION}
|
||||
|
||||
!${MERGE_REQUEST_FOUND}
|
||||
EOF
|
||||
|
||||
fi;
|
||||
|
||||
- | # Store the changes commit for the tag
|
||||
export CHANGE_COMMIT=$(git log -n1 --format=format:"%H")
|
||||
|
||||
echo "Trace - CHANGE_COMMIT[$CHANGE_COMMIT]"
|
||||
|
||||
if [ "${CI_COMMIT_SHA}" == "${CHANGE_COMMIT}" ]; then
|
||||
|
||||
echo "No changes appear to have been commited!"
|
||||
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
git log -3;
|
||||
|
||||
|
||||
- | # create git tag, if changed
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git tag -m "$(cat artifacts/incremental_changelog.txt)" ${NEW_VERSION} ${CHANGE_COMMIT};
|
||||
|
||||
fi;
|
||||
|
||||
- | # push development to origin
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git push --set-upstream origin development
|
||||
|
||||
fi;
|
||||
|
||||
- | # merge bump changes to master
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
if [ $CI_COMMIT_BRANCH == "master" ]; then
|
||||
|
||||
echo "Trace Checkout master branch";
|
||||
git checkout master;
|
||||
|
||||
echo "Trace merge changes from development branch";
|
||||
git merge --no-ff development;
|
||||
|
||||
echo "Trace push changes to origin";
|
||||
git push origin master;
|
||||
|
||||
fi;
|
||||
|
||||
fi;
|
||||
|
||||
- | # store metadata for use in later stages
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
cat <<EOF > artifacts/metadata.env
|
||||
|
||||
export CHANGE_COMMIT=${CHANGE_COMMIT}
|
||||
|
||||
export MERGE_REQUEST_FOUND=${MERGE_REQUEST_FOUND}
|
||||
|
||||
export NEW_VERSION=${NEW_VERSION}
|
||||
|
||||
export OLD_VERSION=${CURRENT_VERSION}
|
||||
|
||||
export VERSION_BUMPED=${VERSION_BUMPED}
|
||||
|
||||
EOF
|
||||
|
||||
chmod +x artifacts/metadata.env;
|
||||
|
||||
curl \
|
||||
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
--upload-file artifacts/metadata.env \
|
||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${NEW_VERSION}/metadata.env";
|
||||
|
||||
fi;
|
||||
|
||||
- | # Create Version Label
|
||||
if [ "$CREATE_VERSION_LABEL" != "false" ]; then
|
||||
|
||||
curl \
|
||||
--data "name=v${NEW_VERSION}&color=#eee600&description=Version%20that%20is%20affected" \
|
||||
--header "PRIVATE-TOKEN: $GIT_COMMIT_TOKEN" \
|
||||
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/labels"
|
||||
|
||||
fi;
|
||||
|
||||
- | # push git tag to origin
|
||||
if [ "0$VERSION_BUMPED" == "00" ]; then
|
||||
|
||||
git push --tags
|
||||
|
||||
fi;
|
||||
|
||||
artifacts:
|
||||
untracked: false
|
||||
when: always
|
||||
expire_in: "3 days"
|
||||
paths:
|
||||
- "artifacts/*"
|
||||
rules:
|
||||
|
||||
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
|
||||
when: never
|
||||
|
||||
- if: # Occur on merge
|
||||
$CI_COMMIT_BRANCH == "development"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
allow_failure: true
|
||||
when: manual
|
||||
|
||||
- if: # Occur on merge
|
||||
$CI_COMMIT_BRANCH == "master"
|
||||
&&
|
||||
(
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
||
|
||||
$CI_PIPELINE_SOURCE == "web"
|
||||
)
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
# Feature Branch / git tag
|
||||
.ansible_collection_build:
|
||||
stage: build
|
||||
image: python:3.11-bookworm
|
||||
before_script:
|
||||
- | # Exit if mandatory variables not defined. On the first job in the pipeline for release.
|
||||
if [ "$CI_COMMIT_TAG" ]; then
|
||||
|
||||
if [ "0$ANSIBLE_GALAXY_UPLOAD_TOKEN" == "0" ]; then
|
||||
|
||||
echo variable ANSIBLE_GALAXY_UPLOAD_TOKEN must be set;
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
if [ "0$ANSIBLE_GALAXY_NAMESPACE" == "0" ]; then
|
||||
|
||||
echo variable ANSIBLE_GALAXY_NAMESPACE must be set;
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
if [ "0$ANSIBLE_GALAXY_PACKAGE_NAME" == "0" ]; then
|
||||
|
||||
echo variable ANSIBLE_GALAXY_PACKAGE_NAME must be set;
|
||||
exit 1;
|
||||
|
||||
fi;
|
||||
|
||||
fi
|
||||
|
||||
- | # Install python deps
|
||||
pip install \
|
||||
ansible==9.2.0
|
||||
|
||||
- | # Setup git to be on the tagged commit
|
||||
if [ "${CI_COMMIT_TAG}" ]; then
|
||||
|
||||
echo "setting up git to be on revision ${CI_COMMIT_TAG}";
|
||||
|
||||
git log -2;
|
||||
|
||||
git fetch -fpvt;
|
||||
|
||||
git pull origin development --rebase;
|
||||
|
||||
git checkout tags/${CI_COMMIT_TAG} -b development;
|
||||
|
||||
git log -2;
|
||||
|
||||
fi;
|
||||
|
||||
script:
|
||||
|
||||
- | # Build the collection
|
||||
ansible-galaxy collection build . --verbose --force --output-path artifacts/galaxy/
|
||||
|
||||
artifacts:
|
||||
untracked: false
|
||||
when: on_success
|
||||
expire_in: "3 days"
|
||||
paths:
|
||||
- "artifacts/*"
|
||||
rules:
|
||||
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: on_success
|
||||
|
||||
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
|
||||
when: never
|
||||
|
||||
- if: # Occur on merge
|
||||
$CI_COMMIT_BRANCH == "development"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
- if:
|
||||
$CI_COMMIT_BRANCH != "development"
|
||||
&&
|
||||
$CI_COMMIT_BRANCH != "master"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
# store built package in generic package registry
|
||||
.ansible_collection_stage_package:
|
||||
stage: prepare
|
||||
image: curlimages/curl:latest
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
environment:
|
||||
name: Gitlab Package Registry
|
||||
url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/
|
||||
script:
|
||||
- | # Store collection
|
||||
curl \
|
||||
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
--upload-file artifacts/galaxy/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz \
|
||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz"
|
||||
|
||||
- | # Fetch Release Notes
|
||||
mkdir -p artifacts;
|
||||
|
||||
curl \
|
||||
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
-o artifacts/release_notes.md \
|
||||
${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/release_notes.md
|
||||
|
||||
echo "Release notes fetched";
|
||||
|
||||
ls -lR artifacts/
|
||||
|
||||
artifacts:
|
||||
untracked: false
|
||||
when: on_success
|
||||
expire_in: "3 days"
|
||||
paths:
|
||||
- "artifacts/*"
|
||||
rules:
|
||||
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: on_success
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
# Only on git tag
|
||||
.ansible_collection_release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
script:
|
||||
|
||||
- ls -lR artifacts/
|
||||
|
||||
release:
|
||||
tag_name: $CI_COMMIT_TAG
|
||||
description: ./artifacts/release_notes.md
|
||||
name: $CI_COMMIT_TAG
|
||||
assets:
|
||||
links:
|
||||
- name: 'Ansible Galaxy'
|
||||
url: https://galaxy.ansible.com/ui/repo/published/${ANSIBLE_GALAXY_NAMESPACE}/${ANSIBLE_GALAXY_PACKAGE_NAME}/?version=${CI_COMMIT_TAG}
|
||||
|
||||
- name: ${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
|
||||
url: https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
|
||||
link_type: package
|
||||
|
||||
- name: 'Docker Image: ${DOCKER_IMAGE_PUBLISH_REGISTRY}/${DOCKER_IMAGE_PUBLISH_NAME}:${CI_COMMIT_TAG}'
|
||||
url: ${DOCKER_IMAGE_PUBLISH_URL}
|
||||
link_type: package
|
||||
|
||||
- name: Documentation
|
||||
url: https://nofusscomputing.com/${PAGES_ENVIRONMENT_PATH}
|
||||
milestones:
|
||||
- $CI_MERGE_REQUEST_MILESTONE
|
||||
rules:
|
||||
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: on_success
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
# Only on git tag
|
||||
.ansible_collection_publish_galaxy:
|
||||
stage: publish
|
||||
image: python:3.11-bookworm
|
||||
variables:
|
||||
GIT_STRATEGY: none
|
||||
ANSIBLE_GALAXY_SERVER_URL: https://galaxy.ansible.com
|
||||
environment:
|
||||
name: Ansible Galaxy
|
||||
url: https://galaxy.ansible.com/ui/repo/published/${ANSIBLE_GALAXY_NAMESPACE}/${ANSIBLE_GALAXY_PACKAGE_NAME}/
|
||||
before_script:
|
||||
|
||||
- | # Install python deps
|
||||
pip install \
|
||||
ansible
|
||||
|
||||
pip list;
|
||||
|
||||
- | # Prepare filename for package
|
||||
# mkdir -p artifacts/galaxy;
|
||||
|
||||
# mv collection.tar.gz artifacts/galaxy/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
|
||||
|
||||
# echo "Prepare filename to be in the correct format";
|
||||
|
||||
ls -lR artifacts;
|
||||
|
||||
script:
|
||||
- | # Publish package to Ansible Galaxy
|
||||
ansible-galaxy collection publish \
|
||||
--server ${ANSIBLE_GALAXY_SERVER_URL} \
|
||||
--token ${ANSIBLE_GALAXY_UPLOAD_TOKEN} \
|
||||
--verbose artifacts/galaxy/${ANSIBLE_GALAXY_NAMESPACE}-${ANSIBLE_GALAXY_PACKAGE_NAME}-${CI_COMMIT_TAG}.tar.gz
|
||||
artifacts:
|
||||
untracked: false
|
||||
when: on_success
|
||||
expire_in: "3 days"
|
||||
paths:
|
||||
- "artifacts/*"
|
||||
rules:
|
||||
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: on_success
|
||||
|
||||
- when: never
|
63
ansible/collection/ci-test.gitlab-ci.yml
Normal file
63
ansible/collection/ci-test.gitlab-ci.yml
Normal file
@ -0,0 +1,63 @@
|
||||
# Ansible Collection Unit Test: # what would the unit tests be??
|
||||
|
||||
# stage: test
|
||||
# before_script:
|
||||
|
||||
# - echo. #install deps
|
||||
|
||||
# script:
|
||||
|
||||
# - echo. # what????
|
||||
|
||||
|
||||
Ansible Collection Functional Test:
|
||||
|
||||
stage: test
|
||||
|
||||
# ToDo: refactor lint jobs to be individual so that pipeline linking can occur
|
||||
# needs:
|
||||
# - Ansible Collection CI Lint
|
||||
|
||||
parallel:
|
||||
matrix:
|
||||
- NFC_CI_FUNCTIONAL_TEST: "push"
|
||||
NFC_CI_FUNCTIONAL_TEST_BRANCH: feature
|
||||
- NFC_CI_FUNCTIONAL_TEST: "merge"
|
||||
NFC_CI_FUNCTIONAL_TEST_BRANCH: development
|
||||
- NFC_CI_FUNCTIONAL_TEST: "release"
|
||||
NFC_CI_FUNCTIONAL_TEST_BRANCH: development
|
||||
- NFC_CI_FUNCTIONAL_TEST: "push"
|
||||
NFC_CI_FUNCTIONAL_TEST_BRANCH: development
|
||||
- NFC_CI_FUNCTIONAL_TEST: "merge"
|
||||
NFC_CI_FUNCTIONAL_TEST_BRANCH: master
|
||||
|
||||
script:
|
||||
|
||||
- echo "to be created";
|
||||
|
||||
# ToDo: run ansible playbook to setup, run and wait for each stage
|
||||
|
||||
# ToDo: create build artifact for use with creating a badge for tests, per branch
|
||||
|
||||
artifacts:
|
||||
untracked: true
|
||||
when: on_success
|
||||
expire_in: "90 days"
|
||||
resource_group: ansible_collection_functional_test
|
||||
rules:
|
||||
# turn off until created
|
||||
- when: never
|
||||
|
||||
- if: # development/feature branch
|
||||
$CI_COMMIT_BRANCH != "master" &&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
changes:
|
||||
paths:
|
||||
- 'ansible/collection/*.yml'
|
||||
compare_to: 'development'
|
||||
when: always
|
||||
|
||||
- if: # master branch
|
||||
$CI_COMMIT_BRANCH == "master" &&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
@ -6,7 +6,7 @@ include:
|
||||
|
||||
|
||||
.ansible_playbook:
|
||||
image:
|
||||
image:
|
||||
name: nofusscomputing/ansible-ee:dev
|
||||
pull_policy: always
|
||||
stage: chores
|
||||
@ -21,7 +21,10 @@ include:
|
||||
- echo "[DEBUG] ansible_inventory=$ansible_inventory"
|
||||
- echo "[DEBUG] ansible_playbook=$ansible_playbook"
|
||||
- echo "[DEBUG] ansible_tags=$ansible_tags"
|
||||
- ansible-playbook $ansible_inventory $ANSIBLE_PLAYBOOK_DIR/$ansible_playbook $ansible_tags -vvv
|
||||
- echo "[TRACE] ********************************** start ******************************************"
|
||||
- export
|
||||
- echo "[TRACE] *********************************** end *******************************************"
|
||||
- ansible-playbook $ansible_inventory $ANSIBLE_PLAYBOOK_DIR/$ansible_playbook $ansible_tags --extra-vars "nfc_pb_host=localhost" -vvv
|
||||
rules:
|
||||
# ToDo: at some stage redefine these rules so that the job can run if specified.
|
||||
# - if: '$NFC_AUTO_JOBS == "false"'
|
||||
|
@ -56,15 +56,20 @@ variables:
|
||||
- update-binfmts --display
|
||||
- |
|
||||
|
||||
if [ "0$NFC_IMAGE_DESCRIPTION" != "0" ]; then NFC_IMAGE_DESCRIPTION=${NFC_IMAGE_DESCRIPTION}; else NFC_IMAGE_DESCRIPTION="No Fuss Computing Image"; fi;
|
||||
|
||||
if [ "0$DOCKER_IMAGE_BUILD_TARGET_PLATFORMS" != "0" ]; then
|
||||
|
||||
echo "[DEBUG] building multiarch/specified arch image";
|
||||
|
||||
docker buildx build --platform=$DOCKER_IMAGE_BUILD_TARGET_PLATFORMS . \
|
||||
--label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
|
||||
--label org.opencontainers.image.created="$(date '+%Y-%m-%dT%H:%M:%S%:z')" \
|
||||
--label org.opencontainers.image.description="$NFC_IMAGE_DESCRIPTION" \
|
||||
--label org.opencontainers.image.documentation="$CI_PROJECT_URL" \
|
||||
--label org.opencontainers.image.source="$CI_PROJECT_URL" \
|
||||
--label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
|
||||
--label io.artifacthub.package.readme-url="$CI_PROJECT_URL/-/raw/development/README.md?ref_type=heads" \
|
||||
--label io.artifacthub.package.maintainers='[{"name":"No Fuss Computing","email":"helpdesk@nofusscomputing.com"}]' \
|
||||
--push \
|
||||
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN --build-arg CI_PROJECT_ID=$CI_PROJECT_ID --build-arg CI_API_V4_URL=$CI_API_V4_URL \
|
||||
--file $DOCKER_DOCKERFILE \
|
||||
@ -73,7 +78,7 @@ variables:
|
||||
docker buildx imagetools inspect $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
|
||||
|
||||
# during docker multi platform build there are >=3 additional unknown images added to gitlab container registry. cleanup
|
||||
|
||||
|
||||
DOCKER_MULTI_ARCH_IMAGES=$(docker buildx imagetools inspect "$DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG" --format "{{ range .Manifest.Manifests }}{{ if ne (print .Platform) \"&{unknown unknown [] }\" }}$DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG@{{ println .Digest }}{{end}} {{end}}");
|
||||
|
||||
docker buildx imagetools create $DOCKER_MULTI_ARCH_IMAGES --tag $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
|
||||
@ -85,16 +90,19 @@ variables:
|
||||
echo "[DEBUG] building image";
|
||||
|
||||
docker build . \
|
||||
--label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
|
||||
--label org.opencontainers.image.created="$(date '+%Y-%m-%dT%H:%M:%S%:z')" \
|
||||
--label org.opencontainers.image.description="$NFC_IMAGE_DESCRIPTION" \
|
||||
--label org.opencontainers.image.documentation="$CI_PROJECT_URL" \
|
||||
--label org.opencontainers.image.source="$CI_PROJECT_URL" \
|
||||
--label org.opencontainers.image.url="$CI_PROJECT_URL/-/releases/$(cz -n cz_nfc version --project)" \
|
||||
--label org.opencontainers.image.version="$(cz -n cz_nfc version --project)" \
|
||||
--label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
|
||||
--label io.artifacthub.package.readme-url="$CI_PROJECT_URL/-/raw/development/README.md?ref_type=heads" \
|
||||
--label io.artifacthub.package.maintainers='[{"name":"No Fuss Computing","email":"helpdesk@nofusscomputing.com"}]' \
|
||||
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN --build-arg CI_PROJECT_ID=$CI_PROJECT_ID --build-arg CI_API_V4_URL=$CI_API_V4_URL \
|
||||
--file $DOCKER_DOCKERFILE \
|
||||
--tag $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
|
||||
|
||||
|
||||
docker push $DOCKER_IMAGE_BUILD_REGISTRY/$DOCKER_IMAGE_BUILD_NAME:$DOCKER_IMAGE_BUILD_TAG;
|
||||
|
||||
fi
|
||||
|
284
docs/projects/gitlab-ci/ansible/collection.md
Normal file
284
docs/projects/gitlab-ci/ansible/collection.md
Normal file
@ -0,0 +1,284 @@
|
||||
---
|
||||
title: Ansible Collection
|
||||
description: How to use No Fuss Computings gitlab-ci job for running Ansible Collection CI/CD Pipelines
|
||||
date: 2024-02-16
|
||||
template: project.html
|
||||
about: https://gitlab.com/nofusscomputing/projects/gitlab-ci
|
||||
---
|
||||
|
||||
This CI/CD template contains all of the CI jobs required for a pipeline for an Ansible Collection Project.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
The following requirements are needed to run these CI/CD jobs. As we use [commitizen](https://commitizen-tools.github.io/commitizen/) for the versioning system, your commits will be required to be in [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/). The configuration for commitizen is within a `.cz.yaml` file which you will need to add to your repository root directory.
|
||||
|
||||
|
||||
### Gitlab Features
|
||||
|
||||
| Feature | Setting | Notes |
|
||||
|:---|:---:|:---|
|
||||
| Package Registry | On | Storage of pipeline artifacts and the built package. |
|
||||
| Releases | On | Gitlab releases are created as part of the pipeline. |
|
||||
|
||||
|
||||
### Variables
|
||||
|
||||
To be able to upload to Ansible Galaxy, you will be required to provide the jobs, the following Variables That should be set as CI/CD variables (`<Project> -> Settings -> CI/CD Settings -> Variables`).
|
||||
|
||||
| Variable | Settings | Notes |
|
||||
|:---|:---:|:---|
|
||||
| `ANSIBLE_GALAXY_UPLOAD_TOKEN` | `masked`, `protected` | |
|
||||
| `VERSION_BUMP_INCREMENT` | `major`, `minor`, `patch` | Used for manual run of the job. After setting the variable, that type of version bump will occur. |
|
||||
|
||||
Within your `.gitlab-ci.yml` file there are varibales to be set, please see below.
|
||||
|
||||
|
||||
### .gitlab-ci.yaml Changes
|
||||
|
||||
To include these jobs in your CI/CD Project add our gitlab-ci project as a submodule to your project `git submodule add https://gitlab.com/nofusscomputing/projects/gitlab-ci/`. Then update your projects `.gitlab-ci.yml` file to include the following:
|
||||
|
||||
``` yaml
|
||||
variables:
|
||||
ANSIBLE_GALAXY_SERVER_URL: https://galaxy.ansible.com # Optional, default=(as displayed)String. URL to the Galaxy server for uploads
|
||||
ANSIBLE_GALAXY_NAMESPACE: "" # Mandatory, String. The ansible galaxy upload namespace
|
||||
ANSIBLE_GALAXY_PACKAGE_NAME: "" # Mandatory, String. The Ansible Galaxy package name
|
||||
|
||||
include:
|
||||
- project: nofusscomputing/projects/gitlab-ci
|
||||
ref: <git ref> # branch, git tag, commit etc
|
||||
file:
|
||||
- .gitlab-ci_common.yaml
|
||||
- template/ansible-collection.gitlab-ci.yaml
|
||||
```
|
||||
|
||||
|
||||
## CI/CD Jobs
|
||||
|
||||
This template contains the following CI/CD Jobs
|
||||
|
||||
- `Create Release`
|
||||
|
||||
- `Ansible Lint`
|
||||
|
||||
- `Ansible Lint (galaxy.yml)`
|
||||
|
||||
- `Build Collection`
|
||||
|
||||
- `Stage Collection`
|
||||
|
||||
- `Gitlab Release`
|
||||
|
||||
- `Ansible Galaxy`
|
||||
|
||||
for a detail description of each job, please see below.
|
||||
|
||||
|
||||
### Create Release
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `manual`
|
||||
|
||||
- **merge to**: `manual`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `always`
|
||||
|
||||
- **merge to**: `always`
|
||||
|
||||
- **git tag**: `never`
|
||||
|
||||
Create a release. It's only triggered on merge to the `development` and `master` branches. The last stage of this job is to create a git tag which matches the version to be released. The creation of the git tag, starts the remainder of the release cycle. On the `development` branch (when the job is triggered as it's a manual job) an `alpha` release is created and on the `master` branch, a full release is created.
|
||||
|
||||
|
||||
### Ansible Lint
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `manual`
|
||||
|
||||
- **merge to**: `manual`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **git tag**: `never`
|
||||
|
||||
Lints the yaml files in directories `meta`, `playbooks` and `roles`. This job will not fail the pipeline. There are XUnit test reports created for thyis job so you can see any liniting errors.
|
||||
|
||||
|
||||
### Ansible Lint (galaxy.yml)
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `always`
|
||||
|
||||
- **merge to**: `always`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `always`
|
||||
|
||||
- **merge to**: `always`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **git tag**: `always`
|
||||
|
||||
Lints the `galaxy.yml` file. This job is designed to fail the pipeline, as an incorrectly formated `galaxy.yml` file can prevent an upload of the collection to Ansible Galaxy. There is a XUnit test report created for thyis job so you can see any liniting errors.
|
||||
|
||||
|
||||
### Build Collection
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `always`
|
||||
|
||||
- **merge to**: `always`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `always`
|
||||
|
||||
- **merge to**: `always`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **git tag**: `always`
|
||||
|
||||
Builds the collection.
|
||||
|
||||
### Stage Collection
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **git tag**: `always`
|
||||
|
||||
Adds the collection to Gitlab Packages Regsitry as a generic package. This location is used to store the package.
|
||||
|
||||
|
||||
### Gitlab Release
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **git tag**: `always`
|
||||
|
||||
Creates a Gitlab release.
|
||||
|
||||
|
||||
### Ansible Galaxy
|
||||
|
||||
Triggered:
|
||||
|
||||
- **Feature branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **development branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **master branch**:
|
||||
|
||||
- **push**: `never`
|
||||
|
||||
- **merge to**: `never`
|
||||
|
||||
- **git tag**: `always`
|
||||
|
||||
Uploads the package to Ansible Galaxy.
|
||||
|
||||
|
||||
## CI Tests
|
||||
|
||||
Still to be developed
|
||||
|
||||
|
||||
## Definition
|
||||
|
||||
``` yaml title="template/ansible-collection.gitlab-ci.yaml" linenums="1"
|
||||
|
||||
--8<-- "template/ansible-collection.gitlab-ci.yaml"
|
||||
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
``` yaml title=".gitlab-ci_common.yaml" linenums="1"
|
||||
|
||||
--8<-- ".gitlab-ci_common.yaml"
|
||||
|
||||
```
|
@ -88,7 +88,6 @@ commit footer refs:
|
||||
- git remote add origin $CI_REPOSITORY_URL
|
||||
- git fetch --all
|
||||
- git checkout --track origin/$CI_COMMIT_BRANCH
|
||||
- git submodule update --init
|
||||
script:
|
||||
- commit_footer > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME.junit.xml"
|
||||
artifacts:
|
||||
|
@ -57,7 +57,7 @@ class Commits:
|
||||
footer_line = git_message.split("\n")
|
||||
footer_line = footer_line[(len(footer_line)-1)]
|
||||
|
||||
commit_footer = re.findall(r"([\!|\#][0-9]+)", str(git_message))
|
||||
commit_footer = re.findall(r"([\!|\#][\d|not]+)", str(git_message))
|
||||
|
||||
if len(commit_footer) > 0:
|
||||
footer = commit_footer
|
||||
|
@ -22,6 +22,17 @@
|
||||
- ls -la $PYTHON_VERSION
|
||||
- if [ $ANSIBLE_LINT_JUNIT > 0 ]; then echo "Error ANSIBLE_LINT_JUNIT failed with $ANSIBLE_LINT_JUNIT"; fi
|
||||
- if [ $ANSIBLE_LINT -ge 3 ]; then echo "ansible lint failed with $ANSIBLE_LINT"; exit $ANSIBLE_LINT; fi # don't fail the job?? 1=failed test, 2=failed command i.e. switch/flag
|
||||
- | # Force failure if test must pass set TEST_MUST_PASS=yes
|
||||
if [ "0$TEST_MUST_PASS" == "0yes" ]; then
|
||||
|
||||
echo "Trace TEST_MUST_PASS[${TEST_MUST_PASS}]";
|
||||
|
||||
echo "ansible lint failed with $ANSIBLE_LINT";
|
||||
|
||||
exit $ANSIBLE_LINT;
|
||||
|
||||
fi
|
||||
|
||||
after_script:
|
||||
- echo deactivate
|
||||
artifacts:
|
||||
|
@ -17,7 +17,11 @@ nav:
|
||||
|
||||
- projects/index.md
|
||||
|
||||
- Gitlab CI:
|
||||
- Gitlab CI:
|
||||
|
||||
- Ansible:
|
||||
|
||||
- projects/gitlab-ci/ansible/collection.md
|
||||
|
||||
- Build:
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.MKDocs_Build:
|
||||
image: python:3.7.5-buster
|
||||
image: python:3.11.2-bullseye
|
||||
stage: build
|
||||
variables:
|
||||
GIT_DEPTH: 0
|
||||
|
@ -1,9 +1,16 @@
|
||||
mkdocs==1.2.3
|
||||
mkdocs-minify-plugin==0.5.0
|
||||
mkdocs-material-extensions==1.0.3
|
||||
# MkDocs: show_signature_annotations=True
|
||||
black==25.1.0
|
||||
|
||||
mkdocs==1.5.3
|
||||
mkdocstrings==0.25.1
|
||||
mkdocstrings-python==1.10.3
|
||||
mkdocs-autorefs==1.3.1
|
||||
mkdocs-minify-plugin==0.8.0
|
||||
mkdocs-material-extensions==1.3.1
|
||||
wheel
|
||||
mkdocs-material==8.1.7
|
||||
mkdocs-material==9.5.6
|
||||
./website-template/custom-plugins/mkdocs-plugin-tags
|
||||
mkdocs-git-revision-date-localized-plugin==0.11.1
|
||||
pymdown-extensions==9.1
|
||||
Jinja2==3.0.3
|
||||
mkdocs-git-revision-date-localized-plugin==1.2.2
|
||||
pymdown-extensions==10.7
|
||||
Jinja2==3.1.3
|
||||
griffe==0.49.0
|
101
template/ansible-collection.gitlab-ci.yaml
Normal file
101
template/ansible-collection.gitlab-ci.yaml
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
include:
|
||||
- local: $JOB_ROOT_DIR/ansible/collection/.gitlab-ci.yml
|
||||
- local: $JOB_ROOT_DIR/lint/ansible.gitlab-ci.yaml
|
||||
|
||||
|
||||
Create Release:
|
||||
extends: .ansible_collection_merge
|
||||
needs: []
|
||||
|
||||
|
||||
Ansible Lint:
|
||||
extends: .ansible_linter_defaults
|
||||
image: python:3.11-slim
|
||||
variables:
|
||||
ANSIBLE_LINT_PATH: meta/ playbooks/ roles/
|
||||
needs: []
|
||||
rules:
|
||||
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: always
|
||||
|
||||
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
|
||||
when: never
|
||||
|
||||
- if: # Occur on merge
|
||||
$CI_COMMIT_BRANCH == "development"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
- if:
|
||||
$CI_COMMIT_BRANCH != "development"
|
||||
&&
|
||||
$CI_COMMIT_BRANCH != "master"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
# ToDo: add lint for README.md as ansible Galaxy doesn't seem to like html in the md document. 16 Feb 24.
|
||||
|
||||
|
||||
Ansible Lint (galaxy.yml):
|
||||
extends: .ansible_linter_defaults
|
||||
image: python:3.11-slim
|
||||
variables:
|
||||
ANSIBLE_LINT_PATH: galaxy.yml
|
||||
TEST_MUST_PASS: 'yes'
|
||||
needs: []
|
||||
rules:
|
||||
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: always
|
||||
|
||||
- if: "$CI_COMMIT_AUTHOR =='nfc_bot <helpdesk@nofusscomputing.com>'"
|
||||
when: never
|
||||
|
||||
- if: # Occur on merge
|
||||
$CI_COMMIT_BRANCH == "development"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
- if:
|
||||
$CI_COMMIT_BRANCH != "development"
|
||||
&&
|
||||
$CI_COMMIT_BRANCH != "master"
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
Build Collection:
|
||||
extends: .ansible_collection_build
|
||||
needs:
|
||||
- Ansible Lint
|
||||
- Ansible Lint (galaxy.yml)
|
||||
|
||||
|
||||
Stage Collection:
|
||||
extends: .ansible_collection_stage_package
|
||||
needs:
|
||||
- Build Collection
|
||||
|
||||
|
||||
Gitlab Release:
|
||||
extends: .ansible_collection_release
|
||||
needs:
|
||||
- Stage Collection
|
||||
|
||||
|
||||
Ansible Galaxy:
|
||||
extends: .ansible_collection_publish_galaxy
|
||||
needs:
|
||||
- Stage Collection
|
||||
- Gitlab Release
|
@ -27,7 +27,7 @@ pages:
|
||||
- mv "$CI_PROJECT_DIR/artifacts/build/Documentation.Build/build" public
|
||||
needs: [ 'Documentation.Build' ]
|
||||
environment:
|
||||
name: staging
|
||||
name: Gitlab Pages
|
||||
url: $CI_PAGES_URL/$PAGES_ENVIRONMENT_PATH
|
||||
artifacts:
|
||||
paths:
|
||||
|
99
test/.gitlab-ci.yml
Normal file
99
test/.gitlab-ci.yml
Normal file
@ -0,0 +1,99 @@
|
||||
# This gitlab-ci file is for testing job rules
|
||||
|
||||
|
||||
API Only:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo should only run on
|
||||
rules:
|
||||
- if:
|
||||
$CI_PIPELINE_SOURCE == "api"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
Push Only:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo testing rules
|
||||
rules:
|
||||
- if:
|
||||
$CI_COMMIT_BRANCH != ""
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "push"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
MR-On Merging Only:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo should only run on merging a MR
|
||||
rules:
|
||||
- if:
|
||||
$CI_MERGE_REQUEST_IID == ""
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
MR-Not On Merging:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo should never run on merging a MR
|
||||
rules:
|
||||
- if:
|
||||
$CI_MERGE_REQUEST_IID != ""
|
||||
&&
|
||||
$CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
MR-Merge Request Event:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo should only run on merge event
|
||||
rules:
|
||||
- if:
|
||||
$CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
Trigger Only:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo should only run on trigger event
|
||||
rules:
|
||||
- if:
|
||||
$CI_PIPELINE_SOURCE == "trigger"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
||||
|
||||
Web Only:
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- echo should only run on web only trigger
|
||||
rules:
|
||||
- if:
|
||||
$CI_PIPELINE_SOURCE == "web"
|
||||
when: always
|
||||
|
||||
- when: never
|
||||
|
Submodule website-template updated: 4ea7ab29be...db172f4594
Reference in New Issue
Block a user