Compare commits
252 Commits
release/1.
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 63eacd7406 | |||
| 719018e0d6 | |||
| bf5417aa4c | |||
| 5e6f5a1523 | |||
| f729e23a9f | |||
| cc54a82cee | |||
| 806bfe7ae5 | |||
| 7aa1367a46 | |||
| 362750ad08 | |||
| 0657acd0c8 | |||
| 4eb7eff790 | |||
| 282a377a1f | |||
| acdaadedc5 | |||
| 02bcbe831e | |||
| 68993e2ccc | |||
| c469db82cd | |||
| 642940f0a4 | |||
| 8ea7205484 | |||
| 4107e22c4e | |||
| 6ed30bb009 | |||
| 323f2ff92c | |||
| 9b7f13f5bf | |||
| 1473841a5f | |||
| d93cf53105 | |||
| aad652cfd5 | |||
| 9c7bbbbb2c | |||
| 8cb6a6c8b3 | |||
| 584066d228 | |||
| 86157b7393 | |||
| 0a76cc5a68 | |||
| dbd12cf6ab | |||
| 9cb8773e27 | |||
| 0977583776 | |||
| d86f3dfdca | |||
| 0f0fe6ec63 | |||
| 4cf5c612a3 | |||
| 50368f7fa0 | |||
| 10906d8430 | |||
| a0e72af228 | |||
| 1daea2cd79 | |||
| 2bd3aaf048 | |||
| c314bef48d | |||
| 2750be1111 | |||
| d2f35bf48c | |||
| e380ecbd92 | |||
| 62e9fa2e9a | |||
| e23d10806e | |||
| ec42dbb641 | |||
| c0bc3972a7 | |||
| c4aef20994 | |||
| 8e67ec8341 | |||
| 4b76641b2b | |||
| cbef9a0299 | |||
| a229283a45 | |||
| e4681305ee | |||
| ab8dc5f532 | |||
| 4e1d3b01f0 | |||
| 935ee5b2c9 | |||
| 54e8906f98 | |||
| de0380baf5 | |||
| ea7dc679de | |||
| 8a49f75e66 | |||
| e0c37dc036 | |||
| 6cc79fa417 | |||
| 945ac257a1 | |||
| 919aa63a77 | |||
| 579209d521 | |||
| 2ef179dd66 | |||
| d92d4ca09e | |||
| 79999edf2d | |||
| 872806d47a | |||
| deb92dc15a | |||
| 84fd8e7dfd | |||
| 3dc9668436 | |||
| e28031e3bd | |||
| fb42f0b7df | |||
| 2055a848eb | |||
| f0b05cbeda | |||
| 30931618cc | |||
| 08039d982d | |||
| fee65cfac6 | |||
| 45b1ba0cc9 | |||
| 51e70cb5f6 | |||
| cf20485fce | |||
| 5998930c01 | |||
| 3ed3d5b169 | |||
| 4f5fd36962 | |||
| 21dbdaa9c0 | |||
| afcf71cdb5 | |||
| c3739257fa | |||
| efa01db1ff | |||
| 1f055dd76b | |||
| 87a7efd1d2 | |||
| ac9c66371f | |||
| 7efb408637 | |||
| dc9b8c2a6f | |||
| 8c5cd42caa | |||
| c5b5570969 | |||
| 1e6c8475fa | |||
| b025d5f86c | |||
| 52116ff6c9 | |||
| 722d963839 | |||
| 5d148e7153 | |||
| 9ab0e6a822 | |||
| db6054d437 | |||
| 668906398d | |||
| 5cf4b1d71c | |||
| c87cfffd18 | |||
| 2fa5972c9d | |||
| 87d1efe1a2 | |||
| ba38649a9f | |||
| 46c05c1fc3 | |||
| e5661070c8 | |||
| 55b4964798 | |||
| 70823bb3ed | |||
| f1d097a01a | |||
| efa0102109 | |||
| baedbf6841 | |||
| b1fc502fa1 | |||
| 47e74a9cab | |||
| 3e5aa5c10f | |||
| f37b68dedd | |||
| 7a69b9611d | |||
| a0e20856f0 | |||
| 4575438b7d | |||
| 529d38db9f | |||
| ef964fc04e | |||
| 45075cd136 | |||
| 4bed167cf0 | |||
| 971bf4fe61 | |||
| b9bec8b70f | |||
| ada9c3cc9d | |||
| 2d06f6a2f9 | |||
| 148a5c0319 | |||
| a0c372eebb | |||
| 1b63d7c6c7 | |||
| a0e2715e44 | |||
| e46369cded | |||
| 417840b6cc | |||
| c8b0669596 | |||
| 2e2ed2ad14 | |||
| 950fa7d0dc | |||
| 34dbc49075 | |||
| 78e551b686 | |||
| ab91acbad4 | |||
| c16dfadf7b | |||
| 1cdab13068 | |||
| 7846749fde | |||
| a73c5aba19 | |||
| 9e906353fc | |||
| 8a141a0a6c | |||
| e6fbb8515b | |||
| 8dca27b4ac | |||
| 1b7998b388 | |||
| 243a6e755b | |||
| 4f9a03ff42 | |||
| b094022f2b | |||
| a63edbd635 | |||
| 6c53a88bf1 | |||
| fea2141e15 | |||
| c29c168f64 | |||
| 8cf45462f1 | |||
| 14d1577bb7 | |||
| fd1fb54314 | |||
| d8f93f8f9e | |||
| 99d262387d | |||
| d24da4cf0a | |||
| 2ac3189c46 | |||
| 8b4072d500 | |||
| 7255ea2da0 | |||
| 9e448a716d | |||
| 85a837e652 | |||
| 378a8b2c56 | |||
| bd870d721b | |||
| 4e1d59b0e8 | |||
| 4c75cbfef4 | |||
| 45f3acc425 | |||
| 16a68a03f1 | |||
| bf93c49c4c | |||
| e1ca976a6d | |||
| 3914c740c5 | |||
| 5ba8ead424 | |||
| 464dc28a9d | |||
| 0c78a23938 | |||
| 8b43a98da5 | |||
| 1d682a58da | |||
| 31a00e6d49 | |||
| 5689d6e99a | |||
| 5fd1be1d8d | |||
| 83ae4f0ce2 | |||
| b79b99c5bf | |||
| cb0654f398 | |||
| 8b1a55de49 | |||
| 1050584364 | |||
| df1eb6fb89 | |||
| b19c3bdf94 | |||
| 60f24b9f79 | |||
| a0b3a6bf5c | |||
| 463ec9d09c | |||
| 6ab4b3a5db | |||
| 629bbd6ad8 | |||
| e849da09ef | |||
| ad16b1dd46 | |||
| ffef37af6c | |||
| f5159ad1df | |||
| d8b2d168be | |||
| c60b97407f | |||
| 5f3cf0eb29 | |||
| 20c3a66e82 | |||
| c48c24ae67 | |||
| 91a91cd876 | |||
| 32bf3c878d | |||
| f625752f3b | |||
| 358ff939b2 | |||
| 44af92919f | |||
| 5309f01654 | |||
| 2251a3ff34 | |||
| 01bf91aeee | |||
| d425a7f16a | |||
| a3e2143444 | |||
| a2200f77b2 | |||
| 06e518ab7c | |||
| 21832c0d01 | |||
| a1db997227 | |||
| 8669ce1b77 | |||
| 53a46e61b5 | |||
| 3a4132c0d4 | |||
| 504045e17c | |||
| 9aab9546fd | |||
| 48a78e6487 | |||
| ffda7963f9 | |||
| 70013b9c65 | |||
| 7a36f7ca69 | |||
| d56e714b21 | |||
| bcb5915063 | |||
| 82a291f69b | |||
| 1ae683f7d8 | |||
| 94e8153768 | |||
| b8a1ffd020 | |||
| 6391a67b52 | |||
| bcc15b22a3 | |||
| 4292458f5c | |||
| 0e8b3183ee | |||
| ab4eab5d36 | |||
| ac07356556 | |||
| efabc73d3c | |||
| 9cd1491c49 | |||
| 70c53b18a8 | |||
| 81e318b0ac | |||
| a62b66d917 | |||
| 157a641f67 | |||
| 3648086d32 |
@@ -11,29 +11,20 @@ workflow:
|
||||
|
||||
render-job-templates-yml:
|
||||
stage: render
|
||||
image: registry.durp.info/debian:bullseye-slim
|
||||
image: registry.internal.durp.info/debian:bullseye-slim
|
||||
script:
|
||||
- ./scripts/install-curl.sh
|
||||
- ./scripts/install-git.sh
|
||||
- ./scripts/install-yq.sh
|
||||
- ./scripts/render-job-templates.sh
|
||||
- ./scripts/commit-and-push-changes.sh
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
changes:
|
||||
- .gitlab-ci.yml
|
||||
- scripts/**
|
||||
- templates/**
|
||||
- job-templates.yml
|
||||
- job-templates.tpl.yml
|
||||
|
||||
render-pipelines-to-branch:
|
||||
stage: render
|
||||
image: registry.internal.durp.info/debian:bullseye-slim
|
||||
script:
|
||||
- ./scripts/install-curl.sh
|
||||
- ./scripts/install-git.sh
|
||||
- ./scripts/install-yq.sh
|
||||
- ./scripts/render-pipelines-branch.sh
|
||||
- ./scripts/commit-and-push-changes.sh
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH =~ /^release*/
|
||||
@@ -12,7 +12,7 @@ workflow:
|
||||
- if: '$CI_COMMIT_BRANCH && $CI_SCRIPTS_SKIP_PIPELINE != "true"'
|
||||
render-job-templates-yml:
|
||||
stage: render
|
||||
image: registry.durp.info/debian:bullseye-slim
|
||||
image: registry.internal.durp.info/debian:bullseye-slim
|
||||
script:
|
||||
# Begin of install-curl.sh
|
||||
- |
|
||||
@@ -31,7 +31,7 @@ render-job-templates-yml:
|
||||
# End of install-yq.sh
|
||||
|
||||
# Begin of render-job-templates.sh
|
||||
- "# render job-templates.yml from job-templates.tpl.yml\nset -euo pipefail\nfor script in scripts/*.sh; do\n awk -v script_name=\"$(basename \"$script\")\" '\n NR==1 && /^#!/ {printf(\"# Begin of %s\\n\",script_name); next} # strip shebang in first line, print head comment\n /^\\s*$/ {next} # strip any newlines or whitespace\n /^#%%MULTILINE_YAML_START$/ { print \"- |\"; multiline=1; next } # detect start of multiline yaml block, print \"- |\" into output yml\n /^#%%MULTILINE_YAML_END$/ { multiline=0; next } # detect end of multiline yaml block\n multiline==1 {printf(\" %s\\n\",$0)} # print indented script of multiline yaml block\n multiline==0 {printf(\"- !!str %s\\n\",$0)} # not in multiline yaml, just print with \"- !!str\" (explicit yaml tag to avoid any quoting)\n END { printf(\"# End of %s\\n\",script_name) } # print trailing comment\n ' \"$script\" >\"$script.yml\"\ndone\n# start with copy and then edit in place using yq -i\ncat <<EOF >job-templates.yml\n### WARNING ###\n### THIS FILE IS RENDERED! DO NOT EDIT! ANY CHANGE WILL BE REVERTED BY RENDERING PIPELINE\n### Edit the template file job-templates.tpl.yml instead!\nEOF\ncat job-templates.tpl.yml >> job-templates.yml\n# shellcheck disable=SC2016 # \"unquoted $ warning\"\n./yq -i '(.[] | select(keys | .[] | select(tag == \"!!str\") | test(\"^(before_|after_|)script$\")) | .\"*script\") ref $scripts\n | ($scripts | .. | select(. == \"./scripts/*.sh\")) |= (load(. + \".yml\") | .[] style=\"\")\n | ($scripts | .[] | select(type == \"!reference\")) |= ([.] | . style=\"flow\")\n | ($scripts | select(type == \"!!seq\")) |= flatten(1)\n | explode .\n ' job-templates.yml\nfor template in templates/*.tpl.yml\n do \n export pipeline=$(basename $template | sed \"s/.tpl//\")\n cat $template > jobs/$pipeline \n ./yq -i '(.[] | select(keys | .[] | select(tag == \"!!str\") | test(\"^(before_|after_|)script$\")) | .\"*script\") ref $scripts\n | ($scripts | .. | select(. == \"./scripts/*.sh\")) |= (load(. + \".yml\") | .[] style=\"\")\n | ($scripts | .[] | select(type == \"!reference\")) |= ([.] | . style=\"flow\")\n | ($scripts | select(type == \"!!seq\")) |= flatten(1)\n | explode .\n ' jobs/$pipeline\ndone\n"
|
||||
- "# render job-templates.yml from job-templates.tpl.yml\nset -euo pipefail\nfor pwsh in $(find ./scripts -name '*.ps1'); do\n script=$(cat $pwsh)\n sh_file=\"${pwsh%.ps1}.sh\"\n \n # Escape double quotes and dollar signs\n script=\"${script//\\\"/\\\\\\\"}\"\n script=\"${script//\\$/\\\\\\$}\"\n pwsh_command=\"pwsh -c \\\"$script\\\"\"\n echo '#!/usr/bin/env bash' > \"$sh_file\"\n echo '#%%MULTILINE_YAML_START' >> \"$sh_file\"\n echo \"$pwsh_command\" >> \"$sh_file\"\ndone\nfor script in $(find ./scripts -name '*.sh'); do\n awk -v script_name=\"$(basename \"$script\")\" '\n NR==1 && /^#!/ {printf(\"# Begin of %s\\n\",script_name); next} # strip shebang in first line, print head comment\n /^\\s*$/ {next} # strip any newlines or whitespace\n /^#%%MULTILINE_YAML_START$/ { print \"- |\"; multiline=1; next } # detect start of multiline yaml block, print \"- |\" into output yml\n /^#%%MULTILINE_YAML_END$/ { multiline=0; next } # detect end of multiline yaml block\n multiline==1 {printf(\" %s\\n\",$0)} # print indented script of multiline yaml block\n multiline==0 {printf(\"- !!str %s\\n\",$0)} # not in multiline yaml, just print with \"- !!str\" (explicit yaml tag to avoid any quoting)\n END { printf(\"# End of %s\\n\",script_name) } # print trailing comment\n ' \"$script\" >\"$script.yml\"\ndone\n# start with copy and then edit in place using yq -i\ncat <<EOF >job-templates.yml\n### WARNING ###\n### THIS FILE IS RENDERED! DO NOT EDIT! ANY CHANGE WILL BE REVERTED BY RENDERING PIPELINE\n### Edit the template file job-templates.tpl.yml instead!\nEOF\ncat job-templates.tpl.yml >> job-templates.yml\n# shellcheck disable=SC2016 # \"unquoted $ warning\"\n./yq -i '(.[] | select(keys | .[] | select(tag == \"!!str\") | test(\"^(before_|after_|)script$\")) | .\"*script\") ref $scripts\n | ($scripts | .. | select(. == \"./scripts/*.sh\")) |= (load(. + \".yml\") | .[] style=\"\")\n | ($scripts | .[] | select(type == \"!reference\")) |= ([.] | . style=\"flow\")\n | ($scripts | select(type == \"!!seq\")) |= flatten(1)\n | explode .\n ' job-templates.yml\nfor template in templates/*.tpl.yml\n do \n export pipeline=$(basename $template | sed \"s/.tpl//\")\n cat $template > jobs/$pipeline \n ./yq -i '(.[] | select(keys | .[] | select(tag == \"!!str\") | test(\"^(before_|after_|)script$\")) | .\"*script\") ref $scripts\n | ($scripts | .. | select(. == \"./scripts/*.sh\")) |= (load(. + \".yml\") | .[] style=\"\")\n | ($scripts | .[] | select(type == \"!reference\")) |= ([.] | . style=\"flow\")\n | ($scripts | select(type == \"!!seq\")) |= flatten(1)\n | explode .\n ' jobs/$pipeline\ndone\n"
|
||||
# End of render-job-templates.sh
|
||||
|
||||
# Begin of commit-and-push-changes.sh
|
||||
@@ -47,16 +47,9 @@ render-job-templates-yml:
|
||||
git push -o ci.variable="CI_SCRIPTS_SKIP_PIPELINE=true" "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "HEAD:$CI_COMMIT_BRANCH"
|
||||
curl --silent --fail --request POST --form token="$CI_JOB_TOKEN" --form ref="$CI_COMMIT_BRANCH" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline" >/dev/null
|
||||
# End of commit-and-push-changes.sh
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
changes:
|
||||
- .gitlab-ci.yml
|
||||
- scripts/**
|
||||
- templates/**
|
||||
- job-templates.yml
|
||||
- job-templates.tpl.yml
|
||||
render-pipelines-to-branch:
|
||||
stage: render
|
||||
image: registry.internal.durp.info/debian:bullseye-slim
|
||||
script:
|
||||
# Begin of install-curl.sh
|
||||
- |
|
||||
@@ -91,5 +84,3 @@ render-pipelines-to-branch:
|
||||
git push -o ci.variable="CI_SCRIPTS_SKIP_PIPELINE=true" "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "HEAD:$CI_COMMIT_BRANCH"
|
||||
curl --silent --fail --request POST --form token="$CI_JOB_TOKEN" --form ref="$CI_COMMIT_BRANCH" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline" >/dev/null
|
||||
# End of commit-and-push-changes.sh
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH =~ /^release*/
|
||||
|
||||
58
jobs/codescan.yml
Normal file
58
jobs/codescan.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
.generate_sbom:
|
||||
image: registry.internal.durp.info/nixos/nix:latest
|
||||
script:
|
||||
# Begin of syft-install.sh
|
||||
- |
|
||||
#Syft install
|
||||
nix-env -iA nixpkgs.syft
|
||||
# End of syft-install.sh
|
||||
|
||||
# Begin of syft-mkdir.sh
|
||||
- |
|
||||
#mkdir for syft files
|
||||
mkdir $CI_PROJECT_DIR/syft
|
||||
# End of syft-mkdir.sh
|
||||
|
||||
# Begin of syft-go.sh
|
||||
- |
|
||||
#Syft scan for go
|
||||
if [ -f "go.mod" ]; then
|
||||
syft go.mod -o cyclonedx-json=syft/${CI_PROJECT_NAME}.sbom.json
|
||||
fi
|
||||
# End of syft-go.sh
|
||||
|
||||
# Begin of syft-docker.sh
|
||||
- |
|
||||
#Syft scan for docker
|
||||
for i in packages/*.tar.gz;
|
||||
do filename=${i%.*.*.*.tar.gz};
|
||||
filename="$(basename -- "$filename")"
|
||||
syft $i -o cyclonedx-json=syft/$filename.docker.sbom.json;
|
||||
done
|
||||
# End of syft-docker.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/syft
|
||||
.generate_cve:
|
||||
image: registry.internal.durp.info/nixos/nix:latest
|
||||
script:
|
||||
# Begin of grype-install.sh
|
||||
- |
|
||||
#Syft install
|
||||
nix-env -iA nixpkgs.grype
|
||||
# End of grype-install.sh
|
||||
|
||||
# Begin of grype.sh
|
||||
- |
|
||||
#grype scan sboms
|
||||
for i in syft/*.sbom.json;
|
||||
do filename=${i%*.sbom.json};
|
||||
filename=${filename##/};
|
||||
grype $i -o json --file $filename.cve.json;
|
||||
done
|
||||
# End of grype.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/syft
|
||||
@@ -1,5 +1,5 @@
|
||||
.docker-build-container:
|
||||
image: registry.durp.info/docker:20.10.17
|
||||
image: registry.internal.durp.info/docker:20.10.17
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
@@ -21,3 +21,64 @@
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:latest"
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:$VERSION"
|
||||
# End of docker-build.sh
|
||||
.docker_build:
|
||||
image: registry.internal.durp.info/docker:20.10.17
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375/
|
||||
services:
|
||||
- name: docker:dind
|
||||
entrypoint: ["dockerd-entrypoint.sh", "--tls=false"]
|
||||
script:
|
||||
# Begin of version.sh
|
||||
- |
|
||||
#check for Version variable
|
||||
if [ -z "${VERSION}" ]; then
|
||||
# If not, assign a default value
|
||||
VERSION=$CI_COMMIT_SHORT_SHA
|
||||
fi
|
||||
# End of version.sh
|
||||
|
||||
# Begin of build.sh
|
||||
- |
|
||||
#Build Docker Container
|
||||
mkdir $CI_PROJECT_DIR/packages
|
||||
containername=$(echo "$PROJECT_NAME" | awk '{print tolower($0)}')
|
||||
docker build -t $containername .
|
||||
docker save -o $CI_PROJECT_DIR/packages/$containername.$VERSION.tar.gz $containername
|
||||
# End of build.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
.docker_push_gitlab:
|
||||
image: registry.internal.durp.info/docker:20.10.17
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375/
|
||||
services:
|
||||
- name: docker:dind
|
||||
entrypoint: ["dockerd-entrypoint.sh", "--tls=false"]
|
||||
script:
|
||||
# Begin of login.sh
|
||||
- |
|
||||
#Docker Login
|
||||
docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY/$CI_PROJECT_PATH
|
||||
# End of login.sh
|
||||
|
||||
# Begin of push-gitlab.sh
|
||||
- |
|
||||
#Push container to gitlab
|
||||
containername=$(echo "$PROJECT_NAME" | awk '{print tolower($0)}')
|
||||
if echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+)*$'; then
|
||||
tag="latest"
|
||||
else
|
||||
tag="dev"
|
||||
fi
|
||||
docker import $CI_PROJECT_DIR/packages/$containername.$VERSION.tar.gz $CI_REGISTRY/$CI_PROJECT_PATH:$VERSION
|
||||
docker import $CI_PROJECT_DIR/packages/$containername.$VERSION.tar.gz $CI_REGISTRY/$CI_PROJECT_PATH:$tag
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:$VERSION"
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:$tag"
|
||||
# End of push-gitlab.sh
|
||||
|
||||
80
jobs/gitlab.yml
Normal file
80
jobs/gitlab.yml
Normal file
@@ -0,0 +1,80 @@
|
||||
.gitlab-move-files:
|
||||
image: registry.internal.durp.info/debian:latest
|
||||
script:
|
||||
# Begin of movefiles.sh
|
||||
- |
|
||||
#move files to output
|
||||
mkdir $CI_PROJECT_DIR/output
|
||||
for i in $(echo $PROJECT_NAME | tr ";" "\n");
|
||||
do mkdir $CI_PROJECT_DIR/output/$i;
|
||||
cp -r $CI_PROJECT_DIR/$i $CI_PROJECT_DIR/output/;
|
||||
done
|
||||
# End of movefiles.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/output
|
||||
.gitlab-deploy:
|
||||
stage: deploy
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
script:
|
||||
# Begin of update-chart.sh
|
||||
- |
|
||||
pwsh -c "Install-Module -Name powershell-yaml -Confirm:\$false -Force
|
||||
\$template = (Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN'= \$ENV:GITLAB_TOKEN } -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml/raw?ref=main\") | ConvertFrom-Yaml
|
||||
\$template.version = \$ENV:VERSION
|
||||
\$body = @{
|
||||
branch = \"main\"
|
||||
commit_message = \"Update Chart\"
|
||||
content = \"\$(\$template | convertto-yaml)\"
|
||||
} | ConvertTo-Json
|
||||
Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN'= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml\""
|
||||
# End of update-chart.sh
|
||||
environment:
|
||||
name: production
|
||||
url: https://api.durp.info/goapi
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
when: manual
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
.generate-config:
|
||||
stage: build
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
script:
|
||||
# Begin of create-environment.sh
|
||||
- |
|
||||
#test deployment
|
||||
echo "
|
||||
$VERSION:
|
||||
stage: deploy
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
script:
|
||||
" >> generated-config.yml
|
||||
echo '
|
||||
- |
|
||||
pwsh -c "Install-Module -Name powershell-yaml -Confirm:\$false -Force
|
||||
\$template = (Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH/raw?ref=\$ENV:ENVIRONMENT\") | ConvertFrom-Yaml
|
||||
\$template.version = \$ENV:VERSION
|
||||
\$body = @{
|
||||
branch = \"\$ENV:ENVIRONMENT\"
|
||||
commit_message = \"Update Chart\"
|
||||
content = \"\$(\$template | convertto-yaml)\"
|
||||
} | ConvertTo-Json
|
||||
Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH\""
|
||||
needs:
|
||||
- pipeline: $PARENT_PIPELINE_ID
|
||||
job: version
|
||||
' >> generated-config.yml
|
||||
echo "
|
||||
environment:
|
||||
name: $ENVIRONMENT
|
||||
" >> generated-config.yml
|
||||
# End of create-environment.sh
|
||||
artifacts:
|
||||
expire_in: never
|
||||
paths:
|
||||
- generated-config.yml
|
||||
@@ -1,19 +1,20 @@
|
||||
.golang-build-api:
|
||||
.golang-build:
|
||||
variables:
|
||||
GOPROXY: https://nexus.durp.info/repository/go/
|
||||
image: registry.durp.info/golang:1.20
|
||||
#GOPROXY: https://nexus.durp.info/repository/go/
|
||||
image: registry.internal.durp.info/golang:${GO_VERSION}
|
||||
script:
|
||||
# Begin of golang-build-api.sh
|
||||
- "#Build golang api\nexport GOPATH=/go\nexport PATH=$PATH:$GOPATH/bin\nmkdir output\ngo install \ngo install github.com/swaggo/swag/cmd/swag@v1.8.12 \nswag init\nCGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main .\n"
|
||||
# End of golang-build-api.sh
|
||||
# Begin of golang-build.sh
|
||||
- "#Build golang project\nexport GOPATH=/go\nexport PATH=$PATH:$GOPATH/bin\nmkdir output\n#go install \ngo mod download\n# Check if go.mod contains \"swag\"\nif grep -q \"swag\" go.mod; then\n echo \"Found 'swag' in go.mod. Running swag init...\"\n go install github.com/swaggo/swag/cmd/swag@latest\n swag init --parseDependency\nfi\nCGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main .\n"
|
||||
# End of golang-build.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/output
|
||||
.golang-lint:
|
||||
variables:
|
||||
GOPROXY: https://nexus.durp.info/repository/go/
|
||||
image: registry.durp.info/golangci/golangci-lint:latest
|
||||
#GOPROXY: https://nexus.durp.info/repository/go/
|
||||
CGO_ENABLED: 0
|
||||
image: registry.internal.durp.info/golangci/golangci-lint:${GOLANGCI_LINT_VERISON}
|
||||
script:
|
||||
# Begin of golang-lint.sh
|
||||
- |
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
.helm-createchart:
|
||||
image: registry.durp.info/dtzar/helm-kubectl
|
||||
.helm-build:
|
||||
image: registry.internal.durp.info/dtzar/helm-kubectl
|
||||
script:
|
||||
# Begin of helm-addrepo.sh
|
||||
- |
|
||||
#Helm repo add
|
||||
helm repo add --username gitlab-ci-token --password ${CI_JOB_TOKEN} ${CI_PROJECT_NAME} ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/stable
|
||||
# End of helm-addrepo.sh
|
||||
|
||||
# Begin of helm-package.sh
|
||||
- |
|
||||
#Helm Package
|
||||
@@ -17,6 +11,18 @@
|
||||
fi
|
||||
done
|
||||
# End of helm-package.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
.helm-push:
|
||||
image: registry.internal.durp.info/dtzar/helm-kubectl
|
||||
script:
|
||||
# Begin of helm-addrepo.sh
|
||||
- |
|
||||
#Helm repo add
|
||||
helm repo add --username gitlab-ci-token --password ${CI_JOB_TOKEN} ${CI_PROJECT_NAME} ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/stable
|
||||
# End of helm-addrepo.sh
|
||||
|
||||
# Begin of helm-push.sh
|
||||
- "#Helm Push \n \nhelm plugin install https://github.com/chartmuseum/helm-push\nfor chart in packages/*; do\n helm cm-push ./$chart ${CI_PROJECT_NAME}\ndone\n"
|
||||
|
||||
11
jobs/nuget.yml
Normal file
11
jobs/nuget.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
.nuget_push:
|
||||
image: registry.internal.durp.info/dotnet/core/sdk:latest
|
||||
script:
|
||||
# Begin of push.sh
|
||||
- |
|
||||
#Nuget Push
|
||||
dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
|
||||
for i in $(echo $PROJECT_NAME | tr ";" "\n");
|
||||
do dotnet nuget push "${CI_PROJECT_DIR}/packages/$i.$VERSION.nupkg" --source gitlab;
|
||||
done
|
||||
# End of push.sh
|
||||
24
jobs/octopus.yml
Normal file
24
jobs/octopus.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
.octo_package:
|
||||
image: registry.internal.durp.info/octopusdeploy/octo:latest
|
||||
script:
|
||||
# Begin of pack.sh
|
||||
- |
|
||||
#Package with octopus
|
||||
mkdir $CI_PROJECT_DIR/packages
|
||||
for dir in ./output/*/;
|
||||
do dir=${dir%*/};
|
||||
dir=${dir##*/};
|
||||
dotnet /octo/octo.dll pack --id=$dir --version=$VERSION --outFolder=$CI_PROJECT_DIR/packages --basePath=$CI_PROJECT_DIR/output/$dir;
|
||||
done
|
||||
# End of pack.sh
|
||||
artifacts:
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
.octo_release:
|
||||
image: registry.internal.durp.info/octopusdeploy/octo:latest
|
||||
script:
|
||||
# Begin of create_release.sh
|
||||
- |
|
||||
#Octopus Create Release
|
||||
dotnet /octo/octo.dll create-release --project=$OCTO_PROJECT_NAME --releaseNumber=$VERSION --server=https://octopus.internal.durp.info/ --apiKey=$OCTOAPI --packagesFolder=$CI_PROJECT_DIR/packages --gitRef main
|
||||
# End of create_release.sh
|
||||
@@ -3,7 +3,7 @@
|
||||
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
|
||||
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
||||
image:
|
||||
name: registry.durp.info/sonarsource/sonar-scanner-cli:latest
|
||||
name: registry.internal.durp.info/sonarsource/sonar-scanner-cli:latest
|
||||
entrypoint: [""]
|
||||
cache:
|
||||
key: "${CI_JOB_NAME}"
|
||||
|
||||
83
jobs/terraform.yml
Normal file
83
jobs/terraform.yml
Normal file
@@ -0,0 +1,83 @@
|
||||
.terraform_fmt:
|
||||
script:
|
||||
# Begin of cd-workdir.sh
|
||||
- |
|
||||
#change directory
|
||||
cd $WORKDIR
|
||||
# End of cd-workdir.sh
|
||||
|
||||
# Begin of fmt.sh
|
||||
- |
|
||||
#Terraform fmt
|
||||
tofu fmt -diff -check -write=false
|
||||
# End of fmt.sh
|
||||
.terraform_validate:
|
||||
script:
|
||||
# Begin of cd-workdir.sh
|
||||
- |
|
||||
#change directory
|
||||
cd $WORKDIR
|
||||
# End of cd-workdir.sh
|
||||
|
||||
# Begin of init.sh
|
||||
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
|
||||
# End of init.sh
|
||||
|
||||
# Begin of validate.sh
|
||||
- "#Terraform validate\ntofu validate \n"
|
||||
# End of validate.sh
|
||||
.terraform_plan:
|
||||
variables:
|
||||
PLAN: plan.tfplan
|
||||
JSON_PLAN_FILE: tfplan.json
|
||||
script:
|
||||
# Begin of cd-workdir.sh
|
||||
- |
|
||||
#change directory
|
||||
cd $WORKDIR
|
||||
# End of cd-workdir.sh
|
||||
|
||||
# Begin of init.sh
|
||||
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
|
||||
# End of init.sh
|
||||
|
||||
# Begin of plan.sh
|
||||
- "#Terraform plan \napk add --update curl jq \nalias convert_report=\"jq -r '([.resource_changes[].change.actions?]|flatten)|{\\\"create\\\":(map(select(.==\\\"create\\\"))|length),\\\"update\\\":(map(select(.==\\\"update\\\"))|length),\\\"delete\\\":(map(select(.==\\\"delete\\\"))|length)}'\"\ntofu plan -out=$PLAN $ARGUMENTS\ntofu show --json $PLAN | jq -r '([.resource_changes[].change.actions?]|flatten)|{\"create\":(map(select(.==\"create\"))|length),\"update\":(map(select(.==\"update\"))|length),\"delete\":(map(select(.==\"delete\"))|length)}' > $JSON_PLAN_FILE\n"
|
||||
# End of plan.sh
|
||||
artifacts:
|
||||
reports:
|
||||
terraform: $WORKDIR/$JSON_PLAN_FILE
|
||||
.terraform_apply:
|
||||
script:
|
||||
# Begin of cd-workdir.sh
|
||||
- |
|
||||
#change directory
|
||||
cd $WORKDIR
|
||||
# End of cd-workdir.sh
|
||||
|
||||
# Begin of init.sh
|
||||
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
|
||||
# End of init.sh
|
||||
|
||||
# Begin of apply.sh
|
||||
- |
|
||||
#Terraform validate
|
||||
tofu apply -auto-approve $ARGUMENTS
|
||||
# End of apply.sh
|
||||
.terraform_destroy:
|
||||
script:
|
||||
# Begin of cd-workdir.sh
|
||||
- |
|
||||
#change directory
|
||||
cd $WORKDIR
|
||||
# End of cd-workdir.sh
|
||||
|
||||
# Begin of init.sh
|
||||
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
|
||||
# End of init.sh
|
||||
|
||||
# Begin of destroy.sh
|
||||
- |
|
||||
#Terraform validate
|
||||
tofu destroy -auto-approve $ARGUMENTS
|
||||
# End of destroy.sh
|
||||
@@ -1,9 +1,9 @@
|
||||
.version:
|
||||
image: registry.durp.info/gittools/gitversion:5.12.0
|
||||
image: registry.internal.durp.info/gittools/gitversion:5.12.0
|
||||
variables:
|
||||
GIT_DEPTH: "0"
|
||||
script:
|
||||
# Begin of version-number.sh
|
||||
# Begin of version.sh
|
||||
- |
|
||||
#Check for configuration
|
||||
echo "mode: ContinuousDeployment
|
||||
@@ -37,7 +37,8 @@
|
||||
version=$(/tools/dotnet-gitversion /showvariable NuGetVersionV2)
|
||||
echo "VERSION=$version" >> version.env
|
||||
cat version.env
|
||||
# End of version-number.sh
|
||||
# End of version.sh
|
||||
artifacts:
|
||||
expire_in: never
|
||||
reports:
|
||||
dotenv: version.env
|
||||
|
||||
21
pipeline.yml
Normal file
21
pipeline.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
stages:
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
GO_VERSION: "1.22"
|
||||
GOLANGCI_LINT_VERISON: "v1.58.0"
|
||||
UPLOAD_PACKAGE: "false"
|
||||
|
||||
build_go:
|
||||
stage: deploy
|
||||
allow_failure: false
|
||||
trigger:
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'pipelines/go-build.yml'
|
||||
strategy: depend
|
||||
rules:
|
||||
- exists:
|
||||
- "go.mod"
|
||||
47
pipelines/docker-build-generic.yml
Normal file
47
pipelines/docker-build-generic.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
stages:
|
||||
- build
|
||||
- package
|
||||
- publish
|
||||
|
||||
include:
|
||||
- template: Security/Secret-Detection.gitlab-ci.yml
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/docker.yml'
|
||||
- 'jobs/version.yml'
|
||||
|
||||
secret_detection:
|
||||
stage: .pre
|
||||
rules:
|
||||
- when: always
|
||||
allow_failure: false
|
||||
|
||||
version:
|
||||
extends: .version
|
||||
stage: .pre
|
||||
rules:
|
||||
- when: always
|
||||
|
||||
build_container:
|
||||
extends: .docker-build-container
|
||||
stage: build
|
||||
artifacts:
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
|
||||
#publish_container:
|
||||
# extends: .docker_push_gitlab
|
||||
# stage: publish
|
||||
# needs:
|
||||
# - job: version
|
||||
# artifacts: true
|
||||
# - job: build_container
|
||||
# artifacts: true
|
||||
# rules:
|
||||
# - if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
# - if: $CI_COMMIT_BRANCH =~ 'main'
|
||||
# - when: never
|
||||
63
pipelines/gitlab_generic_packages.yml
Normal file
63
pipelines/gitlab_generic_packages.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
stages:
|
||||
- build
|
||||
- package
|
||||
- publish
|
||||
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/octopus.yml'
|
||||
- 'jobs/version.yml'
|
||||
- 'jobs/nuget.yml'
|
||||
- 'jobs/gitlab.yml'
|
||||
|
||||
version:
|
||||
extends: .version
|
||||
stage: .pre
|
||||
rules:
|
||||
- when: always
|
||||
|
||||
build:
|
||||
extends: .gitlab-move-files
|
||||
stage: build
|
||||
|
||||
package:
|
||||
extends: .octo_package
|
||||
stage: package
|
||||
needs:
|
||||
- job: build
|
||||
artifacts: true
|
||||
- job: version
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
- if: $CI_COMMIT_BRANCH =~ 'main'
|
||||
- when: never
|
||||
|
||||
upload:
|
||||
extends: .nuget_push
|
||||
stage: package
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
- job: package
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
- if: $CI_COMMIT_BRANCH =~ 'main'
|
||||
- when: never
|
||||
|
||||
publish:
|
||||
extends: .octo_release
|
||||
stage: publish
|
||||
needs:
|
||||
- job: package
|
||||
artifacts: true
|
||||
- job: version
|
||||
artifacts: true
|
||||
- job: upload
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
- if: $CI_COMMIT_BRANCH =~ 'main'
|
||||
- when: never
|
||||
61
pipelines/go-build.yml
Normal file
61
pipelines/go-build.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
stages:
|
||||
- build
|
||||
- validate
|
||||
- publish
|
||||
|
||||
include:
|
||||
- template: Security/Secret-Detection.gitlab-ci.yml
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/golang.yml'
|
||||
- 'jobs/golang.yml'
|
||||
- 'jobs/docker.yml'
|
||||
- 'rules/rules.yml'
|
||||
- 'pipelines/templates/security.yml'
|
||||
|
||||
golang-lint:
|
||||
extends: .golang-lint
|
||||
stage: validate
|
||||
rules:
|
||||
- !reference [.mr_only_rules, rules]
|
||||
|
||||
docker-build:
|
||||
extends: .docker-build-container
|
||||
stage: build
|
||||
needs:
|
||||
- job: gobuild
|
||||
artifacts: true
|
||||
- pipeline: $PARENT_PIPELINE_ID
|
||||
job: version
|
||||
rules:
|
||||
- !reference [.docker_rules, rules]
|
||||
|
||||
gobuild:
|
||||
variables:
|
||||
GOPROXY: https://nexus.durp.info/repository/go/
|
||||
extends: .golang-build
|
||||
stage: build
|
||||
rules:
|
||||
- !reference [.default_mr_rules, rules]
|
||||
|
||||
#docker-build:
|
||||
# extends: .docker_build
|
||||
# stage: build
|
||||
# needs:
|
||||
# - job: gobuild
|
||||
# artifacts: true
|
||||
# - pipeline: $PARENT_PIPELINE_ID
|
||||
# job: version
|
||||
# rules:
|
||||
# - !reference [.docker_rules, rules]
|
||||
#docker-push:
|
||||
# extends: .docker_push_gitlab
|
||||
# stage: publish
|
||||
# needs:
|
||||
# - job: docker-build
|
||||
# artifacts: true
|
||||
# - pipeline: $PARENT_PIPELINE_ID
|
||||
# job: version
|
||||
# rules:
|
||||
# - !reference [.docker_publish_rules, rules]
|
||||
@@ -1,56 +0,0 @@
|
||||
stages:
|
||||
- build
|
||||
- package
|
||||
- publish
|
||||
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: main
|
||||
file:
|
||||
- 'jobs/version.yml'
|
||||
- 'jobs/sonarqube.yml'
|
||||
- 'jobs/golang.yml'
|
||||
- 'jobs/docker.yml'
|
||||
- 'jobs/helm.yml'
|
||||
|
||||
version:
|
||||
extends: .version
|
||||
stage: .pre
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
|
||||
sonarqube:
|
||||
extends: .sonarcloud-check
|
||||
stage: .pre
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main' || $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||
|
||||
golang-lint:
|
||||
extends: .golang-lint
|
||||
stage: .pre
|
||||
|
||||
gobuild:
|
||||
extends: .golang-build-api
|
||||
stage: build
|
||||
|
||||
docker:
|
||||
extends: .docker-build-container
|
||||
stage: publish
|
||||
needs:
|
||||
- job: gobuild
|
||||
artifacts: true
|
||||
- job: version
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
|
||||
helm:
|
||||
extends: .helm-createchart
|
||||
stage: publish
|
||||
needs:
|
||||
- job: gobuild
|
||||
artifacts: false
|
||||
- job: version
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
39
pipelines/helm.yml
Normal file
39
pipelines/helm.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
stages:
|
||||
- build
|
||||
- publish
|
||||
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/version.yml'
|
||||
- 'jobs/helm.yml'
|
||||
|
||||
version:
|
||||
extends: .version
|
||||
stage: .pre
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
|
||||
helm-build:
|
||||
extends: .helm-build
|
||||
stage: build
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
|
||||
helm-push:
|
||||
extends: .helm-push
|
||||
stage: publish
|
||||
needs:
|
||||
- job: helm-build
|
||||
artifacts: true
|
||||
- job: version
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
25
pipelines/octo-templates.yml
Normal file
25
pipelines/octo-templates.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
stages:
|
||||
- package
|
||||
- publish
|
||||
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/version.yml'
|
||||
- 'jobs/octopus.yml'
|
||||
|
||||
|
||||
version:
|
||||
extends: .version
|
||||
stage: .pre
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
|
||||
pack:
|
||||
variables:
|
||||
WORKDIR: $CI_PROJECT_DIR
|
||||
extends: .octo_package
|
||||
stage: package
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == 'main'
|
||||
43
pipelines/templates/security.yml
Normal file
43
pipelines/templates/security.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
stages:
|
||||
- build
|
||||
|
||||
include:
|
||||
- template: Security/Secret-Detection.gitlab-ci.yml
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/codescan.yml'
|
||||
- 'jobs/sonarqube.yml'
|
||||
- 'rules/rules.yml'
|
||||
|
||||
secret_detection:
|
||||
stage: validate
|
||||
rules:
|
||||
- !reference [.mr_only_rules, rules]
|
||||
allow_failure: false
|
||||
|
||||
generate_sbom:
|
||||
extends: .generate_sbom
|
||||
stage: build
|
||||
needs:
|
||||
- job: docker-build
|
||||
optional: true
|
||||
artifacts: true
|
||||
rules:
|
||||
- !reference [.mr_only_rules, rules]
|
||||
|
||||
generate_cve:
|
||||
extends: .generate_cve
|
||||
stage: build
|
||||
needs:
|
||||
- job: generate_sbom
|
||||
artifacts: true
|
||||
rules:
|
||||
- !reference [.mr_only_rules, rules]
|
||||
|
||||
sonarqube:
|
||||
extends: .sonarcloud-check
|
||||
stage: validate
|
||||
allow_failure: true
|
||||
rules:
|
||||
- !reference [.sonarqube_rules, rules]
|
||||
37
pipelines/terraform-gitlab.yml
Normal file
37
pipelines/terraform-gitlab.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
stages:
|
||||
- plan
|
||||
- apply
|
||||
- destroy
|
||||
|
||||
variables:
|
||||
WORKDIR: $CI_PROJECT_DIR/.tf
|
||||
GITLAB_TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/gitlab
|
||||
TF_VAR_GITLAB_PROJECT_ID: $CI_PROJECT_ID
|
||||
TF_VAR_GITLAB_PROJECT_NAME: $CI_PROJECT_NAME
|
||||
TF_VAR_GITLAB_TOKEN: $CI_JOB_TOKEN
|
||||
|
||||
image:
|
||||
name: registry.durp.info/hashicorp/terraform:light
|
||||
#name: hashicorp/terraform:light
|
||||
entrypoint: [""]
|
||||
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/terraform.yml'
|
||||
|
||||
format:
|
||||
stage: .pre
|
||||
allow_failure: false
|
||||
extends: .terraform_fmt
|
||||
|
||||
validate:
|
||||
stage: .pre
|
||||
allow_failure: false
|
||||
extends: .terraform_validate
|
||||
|
||||
apply:
|
||||
stage: apply
|
||||
allow_failure: false
|
||||
extends: .terraform_apply
|
||||
94
pipelines/terraform.yml
Normal file
94
pipelines/terraform.yml
Normal file
@@ -0,0 +1,94 @@
|
||||
stages:
|
||||
- plan
|
||||
- apply
|
||||
- destroy
|
||||
|
||||
variables:
|
||||
WORKDIR: $CI_PROJECT_DIR/terraform
|
||||
GITLAB_TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${ENVIRONMENT_NAME}
|
||||
|
||||
image:
|
||||
name: registry.internal.durp.info/opentofu/opentofu:latest
|
||||
entrypoint: [""]
|
||||
|
||||
include:
|
||||
- project: 'developerdurp/yml'
|
||||
ref: 'main'
|
||||
file:
|
||||
- 'jobs/terraform.yml'
|
||||
|
||||
format:
|
||||
stage: .pre
|
||||
allow_failure: false
|
||||
extends: .terraform_fmt
|
||||
|
||||
validate:
|
||||
stage: .pre
|
||||
allow_failure: false
|
||||
extends: .terraform_validate
|
||||
|
||||
plan-development:
|
||||
stage: plan
|
||||
environment:
|
||||
name: development
|
||||
variables:
|
||||
ENVIRONMENT_NAME: dev
|
||||
allow_failure: false
|
||||
extends: .terraform_plan
|
||||
needs: ["validate","format"]
|
||||
|
||||
plan-production:
|
||||
stage: plan
|
||||
environment:
|
||||
name: production
|
||||
variables:
|
||||
ENVIRONMENT_NAME: prd
|
||||
allow_failure: false
|
||||
extends: .terraform_plan
|
||||
needs: ["validate","format"]
|
||||
|
||||
apply-development:
|
||||
stage: apply
|
||||
environment:
|
||||
name: development
|
||||
variables:
|
||||
ENVIRONMENT_NAME: dev
|
||||
allow_failure: false
|
||||
extends: .terraform_apply
|
||||
rules:
|
||||
- when: manual
|
||||
|
||||
apply-production:
|
||||
stage: apply
|
||||
environment:
|
||||
name: production
|
||||
variables:
|
||||
ENVIRONMENT_NAME: prd
|
||||
allow_failure: false
|
||||
extends: .terraform_apply
|
||||
rules:
|
||||
- when: manual
|
||||
|
||||
destroy-development:
|
||||
stage: destroy
|
||||
environment:
|
||||
name: development
|
||||
variables:
|
||||
ENVIRONMENT_NAME: dev
|
||||
allow_failure: false
|
||||
extends: .terraform_destroy
|
||||
needs: ["apply-development"]
|
||||
rules:
|
||||
- when: manual
|
||||
|
||||
destroy-production:
|
||||
stage: destroy
|
||||
environment:
|
||||
name: production
|
||||
variables:
|
||||
ENVIRONMENT_NAME: prd
|
||||
allow_failure: false
|
||||
extends: .terraform_destroy
|
||||
needs: ["apply-production"]
|
||||
rules:
|
||||
- when: manual
|
||||
47
rules/rules.yml
Normal file
47
rules/rules.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
.default_rules:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
|
||||
.sonarqube_rules:
|
||||
rules:
|
||||
- if: $CI_MERGE_REQUEST_IID
|
||||
exists:
|
||||
- "sonar-project.properties"
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
exists:
|
||||
- "sonar-project.properties"
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
exists:
|
||||
- "sonar-project.properties"
|
||||
|
||||
.default_mr_rules:
|
||||
rules:
|
||||
- if: $CI_MERGE_REQUEST_IID
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
|
||||
.mr_only_rules:
|
||||
rules:
|
||||
- if: $CI_MERGE_REQUEST_IID
|
||||
|
||||
.docker_rules:
|
||||
rules:
|
||||
- if: $CI_MERGE_REQUEST_IID
|
||||
exists:
|
||||
- "Dockerfile"
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
exists:
|
||||
- "Dockerfile"
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
exists:
|
||||
- "Dockerfile"
|
||||
|
||||
.docker_publish_rules:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
exists:
|
||||
- "Dockerfile"
|
||||
- if: $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
exists:
|
||||
- "Dockerfile"
|
||||
4
scripts/cd-workdir.sh
Normal file
4
scripts/cd-workdir.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#change directory
|
||||
cd $WORKDIR
|
||||
9
scripts/checkvariable/version.sh
Normal file
9
scripts/checkvariable/version.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#check for Version variable
|
||||
|
||||
if [ -z "${VERSION}" ]; then
|
||||
# If not, assign a default value
|
||||
VERSION=$CI_COMMIT_SHORT_SHA
|
||||
fi
|
||||
|
||||
8
scripts/docker/build.sh
Normal file
8
scripts/docker/build.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Build Docker Container
|
||||
mkdir $CI_PROJECT_DIR/packages
|
||||
containername=$(echo "$PROJECT_NAME" | awk '{print tolower($0)}')
|
||||
|
||||
docker build -t $containername .
|
||||
docker save -o $CI_PROJECT_DIR/packages/$containername.$VERSION.tar.gz $containername
|
||||
4
scripts/docker/login.sh
Normal file
4
scripts/docker/login.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Docker Login
|
||||
docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY/$CI_PROJECT_PATH
|
||||
16
scripts/docker/push-gitlab.sh
Normal file
16
scripts/docker/push-gitlab.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Push container to gitlab
|
||||
containername=$(echo "$PROJECT_NAME" | awk '{print tolower($0)}')
|
||||
|
||||
if echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+)*$'; then
|
||||
tag="latest"
|
||||
else
|
||||
tag="dev"
|
||||
fi
|
||||
|
||||
docker import $CI_PROJECT_DIR/packages/$containername.$VERSION.tar.gz $CI_REGISTRY/$CI_PROJECT_PATH:$VERSION
|
||||
docker import $CI_PROJECT_DIR/packages/$containername.$VERSION.tar.gz $CI_REGISTRY/$CI_PROJECT_PATH:$tag
|
||||
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:$VERSION"
|
||||
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:$tag"
|
||||
31
scripts/gitlab/create-environment.sh
Normal file
31
scripts/gitlab/create-environment.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#test deployment
|
||||
|
||||
echo "
|
||||
$VERSION:
|
||||
stage: deploy
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
script:
|
||||
" >> generated-config.yml
|
||||
|
||||
echo '
|
||||
- |
|
||||
pwsh -c "Install-Module -Name powershell-yaml -Confirm:\$false -Force
|
||||
\$template = (Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH/raw?ref=\$ENV:ENVIRONMENT\") | ConvertFrom-Yaml
|
||||
\$template.version = \$ENV:VERSION
|
||||
\$body = @{
|
||||
branch = \"\$ENV:ENVIRONMENT\"
|
||||
commit_message = \"Update Chart\"
|
||||
content = \"\$(\$template | convertto-yaml)\"
|
||||
} | ConvertTo-Json
|
||||
Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH\""
|
||||
needs:
|
||||
- pipeline: $PARENT_PIPELINE_ID
|
||||
job: version
|
||||
' >> generated-config.yml
|
||||
|
||||
echo "
|
||||
environment:
|
||||
name: $ENVIRONMENT
|
||||
" >> generated-config.yml
|
||||
8
scripts/gitlab/movefiles.sh
Normal file
8
scripts/gitlab/movefiles.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#move files to output
|
||||
mkdir $CI_PROJECT_DIR/output
|
||||
for i in $(echo $PROJECT_NAME | tr ";" "\n");
|
||||
do mkdir $CI_PROJECT_DIR/output/$i;
|
||||
cp -r $CI_PROJECT_DIR/$i $CI_PROJECT_DIR/output/;
|
||||
done
|
||||
12
scripts/gitlab/update-chart.ps1
Normal file
12
scripts/gitlab/update-chart.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
Install-Module -Name powershell-yaml -Confirm:$false -Force
|
||||
|
||||
$template = (Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN'= $ENV:GITLAB_TOKEN } -Uri "https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml/raw?ref=main") | ConvertFrom-Yaml
|
||||
$template.version = $ENV:VERSION
|
||||
|
||||
$body = @{
|
||||
branch = "main"
|
||||
commit_message = "Update Chart"
|
||||
content = "$($template | convertto-yaml)"
|
||||
} | ConvertTo-Json
|
||||
|
||||
Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN'= $ENV:GITLAB_TOKEN } -ContentType "application/json" -Method Put -body $body -Uri "https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml"
|
||||
14
scripts/gitlab/update-chart.sh
Normal file
14
scripts/gitlab/update-chart.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
pwsh -c "Install-Module -Name powershell-yaml -Confirm:\$false -Force
|
||||
|
||||
\$template = (Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN'= \$ENV:GITLAB_TOKEN } -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml/raw?ref=main\") | ConvertFrom-Yaml
|
||||
\$template.version = \$ENV:VERSION
|
||||
|
||||
\$body = @{
|
||||
branch = \"main\"
|
||||
commit_message = \"Update Chart\"
|
||||
content = \"\$(\$template | convertto-yaml)\"
|
||||
} | ConvertTo-Json
|
||||
|
||||
Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN'= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml\""
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Build golang api
|
||||
export GOPATH=/go
|
||||
export PATH=$PATH:$GOPATH/bin
|
||||
|
||||
mkdir output
|
||||
|
||||
go install
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.8.12
|
||||
swag init
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main .
|
||||
19
scripts/golang-build.sh
Normal file
19
scripts/golang-build.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Build golang project
|
||||
export GOPATH=/go
|
||||
export PATH=$PATH:$GOPATH/bin
|
||||
|
||||
mkdir output
|
||||
|
||||
#go install
|
||||
go mod download
|
||||
|
||||
# Check if go.mod contains "swag"
|
||||
if grep -q "swag" go.mod; then
|
||||
echo "Found 'swag' in go.mod. Running swag init..."
|
||||
go install github.com/swaggo/swag/cmd/swag@latest
|
||||
swag init --parseDependency
|
||||
fi
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main .
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#run linter
|
||||
golangci-lint run ./... --timeout 5m0s
|
||||
golangci-lint run ./... --timeout 5m0s
|
||||
|
||||
5
scripts/helm-login.sh
Normal file
5
scripts/helm-login.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Helm login
|
||||
|
||||
helm registry login ${CI_REGISTRY} -u gitlab-ci-token -p ${CI_JOB_TOKEN}
|
||||
7
scripts/nuget/push.sh
Normal file
7
scripts/nuget/push.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Nuget Push
|
||||
dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
|
||||
for i in $(echo $PROJECT_NAME | tr ";" "\n");
|
||||
do dotnet nuget push "${CI_PROJECT_DIR}/packages/$i.$VERSION.nupkg" --source gitlab;
|
||||
done
|
||||
6
scripts/octopus/create_release.sh
Normal file
6
scripts/octopus/create_release.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Octopus Create Release
|
||||
dotnet /octo/octo.dll create-release --project=$OCTO_PROJECT_NAME --releaseNumber=$VERSION --server=https://octopus.internal.durp.info/ --apiKey=$OCTOAPI --packagesFolder=$CI_PROJECT_DIR/packages --gitRef main
|
||||
|
||||
|
||||
10
scripts/octopus/pack.sh
Normal file
10
scripts/octopus/pack.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Package with octopus
|
||||
mkdir $CI_PROJECT_DIR/packages
|
||||
|
||||
for dir in ./output/*/;
|
||||
do dir=${dir%*/};
|
||||
dir=${dir##*/};
|
||||
dotnet /octo/octo.dll pack --id=$dir --version=$VERSION --outFolder=$CI_PROJECT_DIR/packages --basePath=$CI_PROJECT_DIR/output/$dir;
|
||||
done
|
||||
@@ -2,7 +2,24 @@
|
||||
#%%MULTILINE_YAML_START
|
||||
# render job-templates.yml from job-templates.tpl.yml
|
||||
set -euo pipefail
|
||||
for script in scripts/*.sh; do
|
||||
for pwsh in $(find ./scripts -name '*.ps1'); do
|
||||
script=$(cat $pwsh)
|
||||
sh_file="${pwsh%.ps1}.sh"
|
||||
|
||||
# Escape double quotes and dollar signs
|
||||
script="${script//\"/\\\"}"
|
||||
script="${script//\$/\\\$}"
|
||||
|
||||
pwsh_command="pwsh -c \"$script\""
|
||||
|
||||
echo '#!/usr/bin/env bash' > "$sh_file"
|
||||
echo '#%%MULTILINE_YAML_START' >> "$sh_file"
|
||||
echo "$pwsh_command" >> "$sh_file"
|
||||
done
|
||||
|
||||
|
||||
|
||||
for script in $(find ./scripts -name '*.sh'); do
|
||||
awk -v script_name="$(basename "$script")" '
|
||||
NR==1 && /^#!/ {printf("# Begin of %s\n",script_name); next} # strip shebang in first line, print head comment
|
||||
/^\s*$/ {next} # strip any newlines or whitespace
|
||||
|
||||
4
scripts/scanner/grype-install.sh
Normal file
4
scripts/scanner/grype-install.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Syft install
|
||||
nix-env -iA nixpkgs.grype
|
||||
9
scripts/scanner/grype.sh
Normal file
9
scripts/scanner/grype.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#grype scan sboms
|
||||
|
||||
for i in syft/*.sbom.json;
|
||||
do filename=${i%*.sbom.json};
|
||||
filename=${filename##/};
|
||||
grype $i -o json --file $filename.cve.json;
|
||||
done
|
||||
9
scripts/scanner/syft-docker.sh
Normal file
9
scripts/scanner/syft-docker.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Syft scan for docker
|
||||
|
||||
for i in packages/*.tar.gz;
|
||||
do filename=${i%.*.*.*.tar.gz};
|
||||
filename="$(basename -- "$filename")"
|
||||
syft $i -o cyclonedx-json=syft/$filename.docker.sbom.json;
|
||||
done
|
||||
7
scripts/scanner/syft-go.sh
Normal file
7
scripts/scanner/syft-go.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Syft scan for go
|
||||
|
||||
if [ -f "go.mod" ]; then
|
||||
syft go.mod -o cyclonedx-json=syft/${CI_PROJECT_NAME}.sbom.json
|
||||
fi
|
||||
4
scripts/scanner/syft-install.sh
Normal file
4
scripts/scanner/syft-install.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Syft install
|
||||
nix-env -iA nixpkgs.syft
|
||||
5
scripts/scanner/syft-mkdir.sh
Normal file
5
scripts/scanner/syft-mkdir.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#mkdir for syft files
|
||||
|
||||
mkdir $CI_PROJECT_DIR/syft
|
||||
4
scripts/terraform/apply.sh
Normal file
4
scripts/terraform/apply.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Terraform validate
|
||||
tofu apply -auto-approve $ARGUMENTS
|
||||
4
scripts/terraform/destroy.sh
Normal file
4
scripts/terraform/destroy.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Terraform validate
|
||||
tofu destroy -auto-approve $ARGUMENTS
|
||||
4
scripts/terraform/fmt.sh
Normal file
4
scripts/terraform/fmt.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Terraform fmt
|
||||
tofu fmt -diff -check -write=false
|
||||
4
scripts/terraform/init.sh
Normal file
4
scripts/terraform/init.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Terraform init
|
||||
tofu init -reconfigure -backend-config="address=${GITLAB_TF_ADDRESS}" -backend-config="lock_address=${GITLAB_TF_ADDRESS}/lock" -backend-config="unlock_address=${GITLAB_TF_ADDRESS}/lock" -backend-config="username=gitlab-ci-token" -backend-config="password=${CI_JOB_TOKEN}" -backend-config="lock_method=POST" -backend-config="unlock_method=DELETE" -backend-config="retry_wait_min=5"
|
||||
7
scripts/terraform/plan.sh
Normal file
7
scripts/terraform/plan.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Terraform plan
|
||||
apk add --update curl jq
|
||||
alias convert_report="jq -r '([.resource_changes[].change.actions?]|flatten)|{\"create\":(map(select(.==\"create\"))|length),\"update\":(map(select(.==\"update\"))|length),\"delete\":(map(select(.==\"delete\"))|length)}'"
|
||||
tofu plan -out=$PLAN $ARGUMENTS
|
||||
tofu show --json $PLAN | jq -r '([.resource_changes[].change.actions?]|flatten)|{"create":(map(select(.=="create"))|length),"update":(map(select(.=="update"))|length),"delete":(map(select(.=="delete"))|length)}' > $JSON_PLAN_FILE
|
||||
4
scripts/terraform/validate.sh
Normal file
4
scripts/terraform/validate.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#%%MULTILINE_YAML_START
|
||||
#Terraform validate
|
||||
tofu validate
|
||||
21
templates/codescan.tpl.yml
Normal file
21
templates/codescan.tpl.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
.generate_sbom:
|
||||
image: registry.internal.durp.info/nixos/nix:latest
|
||||
script:
|
||||
- ./scripts/scanner/syft-install.sh
|
||||
- ./scripts/scanner/syft-mkdir.sh
|
||||
- ./scripts/scanner/syft-go.sh
|
||||
- ./scripts/scanner/syft-docker.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/syft
|
||||
|
||||
.generate_cve:
|
||||
image: registry.internal.durp.info/nixos/nix:latest
|
||||
script:
|
||||
- ./scripts/scanner/grype-install.sh
|
||||
- ./scripts/scanner/grype.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/syft
|
||||
@@ -1,5 +1,5 @@
|
||||
.docker-build-container:
|
||||
image: registry.durp.info/docker:20.10.17
|
||||
image: registry.internal.durp.info/docker:20.10.17
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
@@ -10,4 +10,34 @@
|
||||
script:
|
||||
- ./scripts/docker-login.sh
|
||||
- ./scripts/docker-build.sh
|
||||
|
||||
|
||||
.docker_build:
|
||||
image: registry.internal.durp.info/docker:20.10.17
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375/
|
||||
services:
|
||||
- name: docker:dind
|
||||
entrypoint: ["dockerd-entrypoint.sh", "--tls=false"]
|
||||
script:
|
||||
- ./scripts/checkvariable/version.sh
|
||||
- ./scripts/docker/build.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
|
||||
.docker_push_gitlab:
|
||||
image: registry.internal.durp.info/docker:20.10.17
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375/
|
||||
services:
|
||||
- name: docker:dind
|
||||
entrypoint: ["dockerd-entrypoint.sh", "--tls=false"]
|
||||
script:
|
||||
- ./scripts/docker/login.sh
|
||||
- ./scripts/docker/push-gitlab.sh
|
||||
|
||||
35
templates/gitlab.tpl.yml
Normal file
35
templates/gitlab.tpl.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
.gitlab-move-files:
|
||||
image: registry.internal.durp.info/debian:latest
|
||||
script:
|
||||
- ./scripts/gitlab/movefiles.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/output
|
||||
|
||||
.gitlab-deploy:
|
||||
stage: deploy
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
script:
|
||||
- ./scripts/gitlab/update-chart.sh
|
||||
environment:
|
||||
name: production
|
||||
url: https://api.durp.info/goapi
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ '/^release/'
|
||||
when: manual
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
|
||||
.generate-config:
|
||||
stage: build
|
||||
needs:
|
||||
- job: version
|
||||
artifacts: true
|
||||
script:
|
||||
- ./scripts/gitlab/create-environment.sh
|
||||
artifacts:
|
||||
expire_in: never
|
||||
paths:
|
||||
- generated-config.yml
|
||||
@@ -1,9 +1,9 @@
|
||||
.golang-build-api:
|
||||
.golang-build:
|
||||
variables:
|
||||
GOPROXY: https://nexus.durp.info/repository/go/
|
||||
image: registry.durp.info/golang:1.20
|
||||
#GOPROXY: https://nexus.durp.info/repository/go/
|
||||
image: registry.internal.durp.info/golang:${GO_VERSION}
|
||||
script:
|
||||
- ./scripts/golang-build-api.sh
|
||||
- ./scripts/golang-build.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
.golang-lint:
|
||||
variables:
|
||||
GOPROXY: https://nexus.durp.info/repository/go/
|
||||
image: registry.durp.info/golangci/golangci-lint:latest
|
||||
#GOPROXY: https://nexus.durp.info/repository/go/
|
||||
CGO_ENABLED: 0
|
||||
image: registry.internal.durp.info/golangci/golangci-lint:${GOLANGCI_LINT_VERISON}
|
||||
script:
|
||||
- ./scripts/golang-lint.sh
|
||||
- ./scripts/golang-lint.sh
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
.helm-createchart:
|
||||
image: registry.durp.info/dtzar/helm-kubectl
|
||||
.helm-build:
|
||||
image: registry.internal.durp.info/dtzar/helm-kubectl
|
||||
script:
|
||||
- ./scripts/helm-package.sh
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
|
||||
.helm-push:
|
||||
image: registry.internal.durp.info/dtzar/helm-kubectl
|
||||
script:
|
||||
- ./scripts/helm-addrepo.sh
|
||||
- ./scripts/helm-package.sh
|
||||
- ./scripts/helm-push.sh
|
||||
|
||||
4
templates/nuget.tpl.yml
Normal file
4
templates/nuget.tpl.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
.nuget_push:
|
||||
image: registry.internal.durp.info/dotnet/core/sdk:latest
|
||||
script:
|
||||
- ./scripts/nuget/push.sh
|
||||
12
templates/octopus.tpl.yml
Normal file
12
templates/octopus.tpl.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
.octo_package:
|
||||
image: registry.internal.durp.info/octopusdeploy/octo:latest
|
||||
script:
|
||||
- ./scripts/octopus/pack.sh
|
||||
artifacts:
|
||||
paths:
|
||||
- $CI_PROJECT_DIR/packages
|
||||
|
||||
.octo_release:
|
||||
image: registry.internal.durp.info/octopusdeploy/octo:latest
|
||||
script:
|
||||
- ./scripts/octopus/create_release.sh
|
||||
@@ -3,7 +3,7 @@
|
||||
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
|
||||
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
||||
image:
|
||||
name: registry.durp.info/sonarsource/sonar-scanner-cli:latest
|
||||
name: registry.internal.durp.info/sonarsource/sonar-scanner-cli:latest
|
||||
entrypoint: [""]
|
||||
cache:
|
||||
key: "${CI_JOB_NAME}"
|
||||
|
||||
35
templates/terraform.tpl.yml
Normal file
35
templates/terraform.tpl.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
.terraform_fmt:
|
||||
script:
|
||||
- ./scripts/cd-workdir.sh
|
||||
- ./scripts/terraform/fmt.sh
|
||||
|
||||
.terraform_validate:
|
||||
script:
|
||||
- ./scripts/cd-workdir.sh
|
||||
- ./scripts/terraform/init.sh
|
||||
- ./scripts/terraform/validate.sh
|
||||
|
||||
.terraform_plan:
|
||||
variables:
|
||||
PLAN: plan.tfplan
|
||||
JSON_PLAN_FILE: tfplan.json
|
||||
script:
|
||||
- ./scripts/cd-workdir.sh
|
||||
- ./scripts/terraform/init.sh
|
||||
- ./scripts/terraform/plan.sh
|
||||
artifacts:
|
||||
reports:
|
||||
terraform: $WORKDIR/$JSON_PLAN_FILE
|
||||
|
||||
|
||||
.terraform_apply:
|
||||
script:
|
||||
- ./scripts/cd-workdir.sh
|
||||
- ./scripts/terraform/init.sh
|
||||
- ./scripts/terraform/apply.sh
|
||||
|
||||
.terraform_destroy:
|
||||
script:
|
||||
- ./scripts/cd-workdir.sh
|
||||
- ./scripts/terraform/init.sh
|
||||
- ./scripts/terraform/destroy.sh
|
||||
@@ -1,9 +1,10 @@
|
||||
.version:
|
||||
image: registry.durp.info/gittools/gitversion:5.12.0
|
||||
image: registry.internal.durp.info/gittools/gitversion:5.12.0
|
||||
variables:
|
||||
GIT_DEPTH: "0"
|
||||
script:
|
||||
- ./scripts/version-number.sh
|
||||
- ./scripts/gitversion/version.sh
|
||||
artifacts:
|
||||
expire_in: never
|
||||
reports:
|
||||
dotenv: version.env
|
||||
|
||||
Reference in New Issue
Block a user