Commit 4f5fc745 authored by Andres Anaya Amariels's avatar Andres Anaya Amariels 🚀
Browse files

conditional if already exists artifacts folder

parent 094c924c
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -120,20 +120,27 @@ staging_cvs:
  needs: ["staging_linting_docker"]
  stage: staging_cvs
  script: 
   - curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b ../
   - echo "### grype version###"
   - ../grype version
   - mkdir ../grype-outputs
   - export TMP_PWD=$PWD
   - echo "TMP_PWD=$TMP_PWD"
   - echo "### build and push capif-client image###"
   - cd services/capif-client/
   - docker login --username $CI_REGISTRY_USER --password $CAPIF_DOCKER_REGISTRY $CI_REGISTRY
   - docker build -t $CI_REGISTRY/ocf/capif/$CI_COMMIT_REF_SLUG/capif-client:$CI_COMMIT_REF_SLUG .
   - cd $TMP_PWD
   - echo "### Container Vulnerability Scanning###"
   - ../grype $CI_REGISTRY/ocf/capif/$CI_COMMIT_REF_SLUG/capif-client:$CI_COMMIT_REF_SLUG --scope all-layers > ../grype-outputs/grype_capif-client-$CI_COMMIT_REF_SLUG.txt
   - echo "----------------------------------------------------"
   - |
    curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b ../
    echo "### grype version###"
    ../grype version
    DIRECTORY=../grype-outputs
    if [ ! -d "$DIRECTORY" ]; then
      mkdir $DIRECTORY
      echo "Directory created"
    else
      echo "Directory already exists"
    fi
    export TMP_PWD=$PWD
    echo "TMP_PWD=$TMP_PWD"
    echo "### build and push capif-client image###"
    cd services/capif-client/
    docker login --username $CI_REGISTRY_USER --password $CAPIF_DOCKER_REGISTRY $CI_REGISTRY
    docker build -t $CI_REGISTRY/ocf/capif/$CI_COMMIT_REF_SLUG/capif-client:$CI_COMMIT_REF_SLUG .
    cd $TMP_PWD
    echo "### Container Vulnerability Scanning###"
    ../grype $CI_REGISTRY/ocf/capif/$CI_COMMIT_REF_SLUG/capif-client:$CI_COMMIT_REF_SLUG --scope all-layers > ../grype-outputs/grype_capif-client-$CI_COMMIT_REF_SLUG.txt
    echo "----------------------------------------------------"
  artifacts:
    untracked: false
    paths: