'How to reference local files in a Gitlab pipeline (File does not exist error message)

I have the next configuration in my gitlab proyect:

    cont_eval:
          variables:
            DOCKER_TLS_CERTDIR: "/certs"
          stage: cont_eval
          image: docker:stable
          services:
            - docker:19.03.12-dind
          script:
            - echo ${CI_PROJECT_DIR}
            - docker build -t gs .
            - docker image ls
            - docker run 
            -v /var/someContainer:/var/someContainer -v $CI_PROJECT_DIR:/company/reports 
            -v /var/run/docker.sock:/var/run/docker.sock 
            -e URL -e USERNAME 
            -e PASSWORD 
            -e SCANNER_IMAGE 
            -e REGISTRY_URL 
            -e REGISTRY_USER 
            -e REGISTRY_PASSWORD 
            -e LICENSE company/gitlab-nexus-iq-pipeline /company/evaluate 
            -i test $CI_PROJECT_DIR/pom.xml
          artifacts:
            name: "policy-eval"
            paths:
              - $CI_PROJECT_DIR/$CI_PROJECT_NAME-report.html

I'm getting an error referencing the file:

 -i test $CI_PROJECT_DIR/pom.xml

I got the error message: builds/<user>/gitlabproject/pom.xml' does not exist.

This is my project structure: enter image description here

Any ideas of how can I reference this file inside my gitlab configuration?



Solution 1:[1]

Try writing -i test ./pom.xml as the script keyword uses the repository as the current directory.

On another note it will be better to use a docker-compose.yml file to build and run a docker command in Gitlab CI.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 navidanindya