Search code examples
gitlabgitlab-cigitlab-ci-runner

Got an error: This GitLab CI configuration is invalid


This GitLab CI configuration is invalid: jobs:deploy-job rules should be an array containing hashes and arrays of hashes

variables:
  CONTAINER_NAME: "ewq"
  SSH_TARGET: "qwe@11.11.11.31"
  

  IMAGE: "11.11.11.39:5555/ewq:latest"
  SSH_COM: 'sshpass -p secret ssh -o StrictHostKeyChecking=no'  

stages:
  - deploy

deploy-job:
  stage: deploy
  rules:
    - if [ "$CI_COMMIT_SHA" != "$CI_DEPLOY_SHA" ]
  script:
    - $SSH_COM $SSH_TARGET docker pull $IMAGE 
    - $SSH_COM $SSH_TARGET docker stop $CONTAINER_NAME
    - $SSH_COM $SSH_TARGET docker rm $CONTAINER_NAME

My pipeline should start in schelude, and check if there a new commit, if true then deploy.


Solution

  • You need to update the rules.

      rules:
        - if: $CI_COMMIT_SHA != $CI_DEPLOY_SHA
    

    Follow this link for syntax: https://docs.gitlab.com/ee/ci/yaml/#rulesif