Not understanding why my SCP is not working

Hello - been banging my head trying to figure out my deploy isn’t actually scp’ing my file to my remote private server. I am trying to build an Angular 4 app and deploy the zipped dist folder to my server for starters. Below is my config file, anything that stands out that isn’t obvious to me?

# https://circleci.com/docs/2.0/local-cli/
version: 2
jobs:
    # The build job
    build:
        working_directory: ~/project
        docker:
            - image: circleci/node:9-browsers
        steps:
            # Checkout the code from the branch into the working_directory
            - checkout
            # Log the current branch
            - run:
                name: Show current branch
                command: echo ${CIRCLE_BRANCH}
            # Restore local dependencies from cache
            - restore_cache:
                keys:
                - v1-dependencies-{{ checksum "package.json" }}
                - v1-dependencies-
            # Install project dependencies
            - run:
                name: Install local dependencies
                command: npm install
            # Cache local dependencies if they don't exist
            - save_cache:
                key: v1-dependencies-{{ checksum "package.json" }}
                paths:
                    - node_modules
            # Lint the source code
            # - run:
            #     name: Linting
            #     command: npm run lint
            # Test the source code
            # - run:
            #     name: Testing
            #     command: npm run test
            # Build project with different configuration based on
            # the current branch
            - run:
                name: Building
                command: |
                    if [ "${CIRCLE_BRANCH}" == "staging" ]; then
                        npm run build-qa
                    elif [ "${CIRCLE_BRANCH}" == "master" ]; then
                        npm run build-prod
                    else
                        npm run build-dev
                    fi
            - run: 
                name: Packaging dist
                command: zip -r dist.zip dist
            # Cache the dist folder for the deploy job
            - save_cache:
                key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }}
                paths:
                    - dist
    deploy:
        working_directory: ~/project
        docker:
            - image: circleci/node:9-browsers
        steps:
            # Log the current branch
            - run:
                name: Show current branch
                command: echo ${CIRCLE_BRANCH}
            # Restore cache from the build job which contains the
            # dist folder that needs to be deployed
            - restore_cache:
                key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }}
            - add_ssh_keys:
                fingerprints:
                    - "..................."
            - run:
                name: scp dist
                command : sudo scp -i ~/.ssh/id_rsa_........... -P 3022 -r dist.zip tp-dev@..........:~/ 
workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
        filters:
            branches:
                only:
                    - develop
                    - staging
                    - master

My builds are passing - but I do not see my dist.zip file in my server. I confirmed I was able to ssh into my CircleCI container and run my scp command manually and it works!! But not when the workflow runs…

I will appreciate any help.

Upon further checking…

dist.zip: No such file or directory
Exited with code 1

For some reason I wouldn’t have expected this…unless I restored my cache incorrectly?

Ok - for some reason I thought my dist.zip was intermediately in the proejct folder…well I figured out it out.

1 Like

(Nice one for figuring it out. If you wish, you can mark the topic as resolved by clicking the “solved” widget in the appropriate post).