Commit b24069db authored by Clement Bois's avatar Clement Bois
Browse files

fix: use up-to-date image and download yajsv

parent ae35eebc
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
variables:
  YAJSV_IMAGE: "registry.hub.docker.com/amux/yajsv:latest"
  YAJSV_IMAGE: "registry.hub.docker.com/badouralix/curl-jq:latest"
  YAJSV_RELEASE: "https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64"

.kicker-scripts: &kicker-scripts |
  set -e
@@ -29,6 +30,16 @@ variables:
    fi
  }

  function install_yajsv() {
    export PATH=$PATH:$(pwd)
    if ! command -v yajsv > /dev/null
    then
      log_info "Installing yajsv"
      curl -sSL -o ./yajsv "${YAJSV_RELEASE}"
      chmod +x ./yajsv
    fi
  }

# Abstract JSON schema validation job
# $JSON_FILE  : the JSON file to test
# $SCHEMA_URL : the schema url
@@ -38,9 +49,14 @@ variables:
  before_script:
    - !reference [.kicker-scripts]
    - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
    - install_yajsv
  script:
    - 'wget --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$SCHEMA_URL" -O schema.json'
    - 'curl -sSL -o schema.json -H "PRIVATE-TOKEN: $GITLAB_TOKEN" "$SCHEMA_URL"'
    - yajsv -s schema.json "$JSON_FILE"
  cache:
    key: "$CI_COMMIT_REF_NAME-yajsv"
    paths:
      - ./yajsv
  rules:
    # enabled if kicker.json file found
    - exists: