Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
puppet-module-pipeline.yaml 6.29 KiB
---
stages:
  - puppet
  - pre_deploy
  - deploy

workflow:
  rules:
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"'
      when: never
    - if: $CI_COMMIT_BRANCH
    - if: $CI_COMMIT_TAG
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

variables:
  GIT_LFS_SKIP_SMUDGE: 1  # Disable LFS by default

pdk-validate:
  stage: puppet
  image: &PDK
    name: puppet/pdk:3.2.0.1
    pull_policy: if-not-present
  before_script: &pdk-workaround
    - |
      # Applying any necessary PDK workarounds

      PDK_VERSION="$(pdk --version)"
      pdk env 2>/dev/null > /tmp/pdk-env
      source /tmp/pdk-env

      touch Gemfile Gemfile.local

      # For PDK 3.2.0 (it can report as the unreleased 3.1.0)
      if [ "$PDK_VERSION" == "3.1.0" ] || [ "$PDK_VERSION" == "3.2.0" ]; then
        if [ "$PDK_RESOLVED_RUBY_VERSION" == "2.7.8" ]; then
          echo "Locking racc to 1.4.16"
          sed -e '/"racc"/d' -e "/'racc'/d" -i Gemfile Gemfile.local
          echo 'gem "racc", "= 1.4.16"' >> Gemfile.local
        else
          echo "Locking racc to 1.7.3"
          sed -e '/"racc"/d' -e "/'racc'/d" -i Gemfile Gemfile.local
          echo 'gem "racc", "= 1.7.3"' >> Gemfile.local
        fi

        echo "Locking rexml to 3.2.6"
        sed -e '/"rexml"/d' -e "/'rexml'/d" -i Gemfile Gemfile.local
        echo 'gem "rexml", "= 3.2.6"' >> Gemfile.local
      # For PDK 3.0.1
      elif [ "$PDK_VERSION" == "3.0.1" ]; then
        echo "Locking puppet_litmus to 1.2.1"
        sed -e '/"puppet_litmus"/d' -e "/'puppet_litmus'/d" -i Gemfile Gemfile.local
        echo 'gem "puppet_litmus", "= 1.2.1"' >> Gemfile.local

        echo "Locking bolt to 3.27.4"
        sed -e '/"bolt"/d' -e "/'bolt'/d" -i Gemfile Gemfile.local
        echo 'gem "bolt", "= 3.27.4"' >> Gemfile.local

        echo "Locking CFPropertyList to 3.0.6"
        sed -e '/"CFPropertyList"/d' -e "/'CFPropertyList'/d" -i Gemfile Gemfile.local
        echo 'gem "CFPropertyList", "= 3.0.6"' >> Gemfile.local

        echo "Locking nori to 2.6.0"
        sed -e '/"nori"/d' -e "/'nori'/d" -i Gemfile Gemfile.local
        echo 'gem "nori", "= 2.6.0"' >> Gemfile.local
      # For PDK 3.0.0
      elif [ "$PDK_VERSION" == "3.0.0" ]; then
        echo "Locking ffi to 1.15.5"
        sed -e '/"ffi"/d' -e "/'ffi'/d" -i Gemfile Gemfile.local
        echo 'gem "ffi", "= 1.15.5"' >> Gemfile.local
        if [ "$PDK_RESOLVED_RUBY_VERSION" == "2.7.8" ]; then