SCP deployment solution


#1

Hi All,

I have done my research and I am still unable to find the anwser, hence asking.

I would like to deploy (copy via scp) a war file to my vps.

My problem seems to be that the war file that is built is not found on the (new?) machine that is responsible for the deploy job. The project folder is empty.

I think I have the option to add a checkout step to the deploy job, and build again, but I dont think it would make sense. Also I dont want to pull the repo on the vps and do the build again. I simply want to copy the war file from the maven target folder.

Thanks ind advance, and sorry if this is already anwsered, I could not find info.

my yml file:

# Java Maven CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
  build:

    docker:
      - image: circleci/openjdk:8-jdk
          
    working_directory: ~/flapweb-auth-service
    
    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "pom.xml" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: mvn dependency:go-offline

      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "pom.xml" }}
        
      # run tests!
      - run: mvn package

      - store_test_results:  
          path: target/surefire-reports

      - store_artifacts:
          path: target/flapweb-auth-service-1.war

  deploy:
   machine: 
     enabled: true
   working_directory: ~/flapweb-auth-service
   steps: 
     - run:
         name: Deploy Over SSH
         command: | 
            scp -r ~/flapweb-auth-service "$SSH_USER@$SSH_HOST:$SSH_DEPLOY_PATH"


workflows:
  version: 2
  build-and-deploy:
    jobs:
        - build
        - deploy:
            requires:
              - build
            filters:
              branches: 
                only: master

#3

After some more testing I have found the solution! Caching resolves the issue, I just have to cache the war file, so it will be available across different jobs in a workflow.


#4

Great stuff. You can also use workspaces to preserve folders between jobs in a workflow as well.


closed #5

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.