From: Frank Brehm Date: Mon, 20 Dec 2021 15:55:01 +0000 (+0100) Subject: Adding jobs for depoying packages X-Git-Tag: 0.4.1~4^2~13 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=0f8badedfdfd880fb65b76109bbce2f2a8a0fa85;p=pixelpark%2Fpp-admin-tools.git Adding jobs for depoying packages --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbb115c..7c0683c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,6 +19,7 @@ variables: FB_REPOSERVER_GPGKEY_URL: 'http://repo.uhu-banane.de/public/repo.uhu-banane.de.gpg-key2.asc' NOTIFY_ADDRESS: 'frank.brehm@pixelpark.com' SENDER_ADDRESS: 'gitlab-ci@pixelpark.com' + SSH_PRIV_KEY_YUM_REPO: 'nada' USED_TIMEZONE: 'Europe/Berlin' VERSION_PREFIX: 'unknown' YUM_REPO_GPG_ID: 'C0E73F70' @@ -30,6 +31,7 @@ variables: YUM_REPO_GPG_KEY_PUB: 'nada' YUM_REPO_GPG_KEY_SEC: 'nada' +# --------------------------- .docker_job_definition: before_script: - locale -a @@ -57,6 +59,7 @@ variables: - pip install --upgrade pip - pip install -r requirements.txt --upgrade --upgrade-strategy eager +# --------------------------- .test-rules: stage: test rules: @@ -72,36 +75,42 @@ variables: - pip list --format columns - pytest --verbose +# --------------------------- test Python 3.6: extends: - .docker_job_definition - .test-rules image: python:3.6 +# --------------------------- test Python 3.7: extends: - .docker_job_definition - .test-rules image: python:3.7 +# --------------------------- test Python 3.8: extends: - .docker_job_definition - .test-rules image: python:3.8 +# --------------------------- test Python 3.9: extends: - .docker_job_definition - .test-rules image: python:3.9 +# --------------------------- test Python 3.10: extends: - .docker_job_definition - .test-rules image: python:3.10 +# --------------------------- Linter: stage: linter extends: @@ -132,6 +141,7 @@ Linter: - 'test Python 3.9' - 'test Python 3.10' +# --------------------------- .pkg-build-rules: stage: build rules: @@ -245,6 +255,7 @@ Linter: find rpmdir/*RPMS -type f -print0 | xargs --null --no-run-if-empty ls -l -d --color=always +# --------------------------- build CentOS 7 with Python 3.6: variables: EL_MAJOR_VERSION: '7' @@ -259,6 +270,7 @@ build CentOS 7 with Python 3.6: - '.pkg-build-rules' image: centos:7 +# --------------------------- build CentOS 8 with Python 3.8: variables: EL_MAJOR_VERSION: '8' @@ -273,6 +285,7 @@ build CentOS 8 with Python 3.8: - '.pkg-build-rules' image: centos:8 +# --------------------------- .pkg-sign-rules: rules: - if: '$CI_COMMIT_TAG' @@ -332,6 +345,7 @@ build CentOS 8 with Python 3.8: - rpmdir/SRPMS/*.src.rpm expire_in: '1 week' +# --------------------------- Sign EL 7 packages: extends: - '.pkg-sign-rules' @@ -340,6 +354,7 @@ Sign EL 7 packages: dependencies: - 'build CentOS 7 with Python 3.6' +# --------------------------- Sign EL 8 packages: extends: - '.pkg-sign-rules' @@ -348,3 +363,89 @@ Sign EL 8 packages: dependencies: - 'build CentOS 8 with Python 3.8' +# --------------------------- +.rpm-pkg-deploy: + rules: + # - if: '$CI_COMMIT_TAG' + - if: true + when: manual + allow_failure: true + stage: deploy + tags: + - docker_v2 + script: + - hostname -f + - whoami + - pwd + - ls -lA --color=always + - find rpmdir/*RPMS -type f -print0 | xargs --null --no-run-if-empty ls -l -d --color=always + - echo -e "YUM_REPO_USER: ${YUM_REPO_USER}" + - echo -e "YUM_REPO_HOST: ${YUM_REPO_HOST}" + - echo -e "YUM_REPO_DIR: ${YUM_REPO_DIR}" + - | + echo "Ensuring '${HOME}/.ssh/authorized_keys' ..." + mkdir -pv "${HOME}/.ssh" + chmod -v 0700 "${HOME}/.ssh" + echo "${SSH_PRIV_KEY_YUM_REPO}" > "${HOME}/.ssh/authorized_keys" + chmod -v 0600 "${HOME}/.ssh/authorized_keys" + ls -lA "${HOME}/.ssh" + # - 'scp -p -o StrictHostKeyChecking=no rpmdir/RPMS/*/*.rpm ${YUM_REPO_USER}@${YUM_REPO_HOST}:${YUM_REPO_DIR}/${EL_MAJOR_VERSION}/' + # - 'ssh -o StrictHostKeyChecking=no ${YUM_REPO_USER}@${YUM_REPO_HOST} "cd ${YUM_REPO_DIR}/${EL_MAJOR_VERSION}/ && createrepo --update . && chmod -v a+x repodata && chmod -Rv a+r repodata"' + - scp -p -o StrictHostKeyChecking=no rpmdir/SRPMS/*.rpm "${YUM_REPO_USER}@${YUM_REPO_HOST}:${YUM_REPO_DIR}/src/" + - ssh -o StrictHostKeyChecking=no "${YUM_REPO_USER}@${YUM_REPO_HOST}" "cd ${YUM_REPO_DIR}/src/ && createrepo --update . && chmod -v a+x repodata && chmod -Rv a+r repodata" + after_script: + - rm -rf rpmdir + environment: + name: production + +# --------------------------- +Deploy packages EL7: + extends: + - '.rpm-pkg-deploy' + variables: + EL_MAJOR_VERSION: '7' + needs: + - 'Sign EL 7 packages' + dependencies: + - 'Sign EL 7 packages' + +# --------------------------- +Deploy packages EL8: + extends: + - '.rpm-pkg-deploy' + variables: + EL_MAJOR_VERSION: '8' + needs: + - 'Sign EL 8 packages' + dependencies: + - 'Sign EL 8 packages' + +# --------------------------- +# .notify-rules: +# rules: +# - if: '$CI_COMMIT_TAG' +# - if: $CI_COMMIT_BRANCH == "master" +# - if: $CI_COMMIT_BRANCH == "main" +# - if: $CI_COMMIT_BRANCH == "test" +# tags: +# - docker_v2 +# needs: +# - 'Deploy packages EL7' +# - 'Deploy packages EL8' + +# --------------------------- +# Notify Success: +# extends: +# - '.notify-rules' +# allow_failure: true +# script: 'echo -e "Module ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME} (${CI_COMMIT_REF_NAME}): all checks successful\nCommiter: ${GITLAB_USER_NAME} <${GITLAB_USER_EMAIL}>" | mailx -s "Gitlab-CI: Python module fb_tools" -r "$SENDER_ADDRESS" $NOTIFY_ADDRESS' + +# --------------------------- +# Notify Error: +# extends: +# - '.notify-rules' +# allow_failure: true +# when: on_failure +# script: 'echo -e "Error in module ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME} (${CI_COMMIT_REF_NAME})\nPlease check ${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}\n\nCommiter: ${GITLAB_USER_NAME} <${GITLAB_USER_EMAIL}>" | mailx -s "Gitlab-CI error for Python module fb_tools" -r "$SENDER_ADDRESS" "$NOTIFY_ADDRESS"' + +# vim: et tabstop=2 expandtab shiftwidth=2 softtabstop=2 list