Pipeline fails with No such file or directory
Asked by Lokesh M:

This is my bitbucket pipeline file, I am trying to move zip to s3 then deploy to lambda. I am not sure this is the correct way to do but in the pipeline I am getting below error. How to fix it?

```
? /opt/atlassian/pipelines/agent/build/application.zip directory doesn't exist.
```

```

image: node:latest

pipelines:

  default:

    - step:

        name: Install, Build, and Package

        caches:

          - node

        script:

          - npm install

          - npx tsc

          - apt-get update && apt-get install -y zip

          - zip -r application.zip . -x "*.git*" -x "bitbucket-pipelines.yml"

        artifacts:

          - application.zip

    - step:

        name: Deploy to AWS Lambda Dev

        deployment: development

        script:

          - pipe: atlassian/aws-s3-deploy:1.6.0

            variables:

              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID

              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY

              AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION

              S3_BUCKET: $AWS_S3_BUCKET

              LOCAL_PATH: "$BITBUCKET_CLONE_DIR/application.zip"
```

```
          - pipe: atlassian/aws-lambda-deploy:1.11.1

            variables:

              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID

              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY

              AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION

              FUNCTION_NAME: $AWS_FUNCTION_NAME

              COMMAND: 'update'

              S3_BUCKET: $AWS_S3_BUCKET

              S3_KEY: application.zip
```


Answers:
author: Igor Stoyanov
body: [@Lokesh M](/t5/user/viewprofilepage/user-id/5416176) hi. Thanks for your question

```
? /opt/atlassian/pipelines/agent/build/application.zip directory doesn't exist.
```

This error points you that you should pass a directory not a file.  
According to [aws-s3-deploy README](https://bitbucket.org/atlassian/aws-s3-deploy/src/master/):  
LOCAL_PATH - Local path to folder to be deployed.  
Example:  

```
script:  - pipe: atlassian/aws-s3-deploy:1.6.0    variables:      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY      AWS_DEFAULT_REGION: 'us-east-1'      S3_BUCKET: 'my-bucket-name'      LOCAL_PATH: $BITBUCKET_CLONE_DIR      EXTRA_ARGS: "--exclude=* --include=application.zip"
```

<br />

<br />

Regards, Igor


author: Patrik S
body: Hello [@Lokesh M](/t5/user/viewprofilepage/user-id/5416176) and welcome to the Community!

That error message suggests the file application.zip was either not correctly generated in the first step or there were some issues with passing it as an artifact from the first step to the second due to its size.

To confirm whether the file is available in both steps, could you please add a simple ls command in the first and second steps and check for the file's existence?

* **First step** - add the *ls* command right after the zip command to check if the file was created :

  ```
  [...]
  - zip -r application.zip . -x "*.git*" -x "bitbucket-pipelines.yml"

  - ls -la 

  [...]
  ```

* **Second step** - add the *ls* command as the first command in the step to see if the artifact (application.zip) was downloaded and placed in the same location where it was generated:

  ```
  [...]
  script:
    - ls -la

    - pipe: atlassian/aws-s3-deploy:1.6.0

  [...]
  ```

Once you have a new build with those two commands, feel free to share the output of both of them here so we can assist you further.

Thank you, [@Lokesh M](/t5/user/viewprofilepage/user-id/5416176) !

Patrik S


Tags: bitbucket-cloud

cloud