Issue: Missing Files in Build Output (Bitbucket Pipelines)

Mohammad September 4, 2024

Hello Atlassian community,

Any one can help?

 

I am experiencing an issue with my Flutter web build pipeline on Bitbucket. When I run the flutter build web --web-renderer canvaskit --release command locally, the build/web directory contains all necessary files and folders, including the assets directory and the .env file that I manually copy into the directory after the build. However, when running the same pipeline on Bitbucket, the build output is incomplete. The build/web directory on the Bitbucket server does not include the assets directory and the .env file, which are essential for my deployment.

Pipeline Details:

  • I'm using the instrumentisto/flutter:latest Docker image in my pipeline to build the Flutter web application.
  • The .env file is located in an external repository (env-configs), and I attempt to copy it into the build/web directory after the build step.
  • The pipeline proceeds without errors during the build process, but when I check the output, some critical files and directories (like assets and the .env file) are missing.

Key Pipeline Steps:

  1. Install SSH Key: Pulls private repositories.
  2. Clone Environment Variables Repo: Fetches environment-specific config files, including .env.
  3. Build Flutter Web: Executes the flutter build web command.
  4. Copy .env File: Attempts to copy the .env file from env-configs to build/web.
  5. Check Build Output: Lists the contents of build/web to ensure all files are present.
  6. Deploy to FTP: Uses atlassian/ftp-deploy pipe to upload the build output.

What Works Locally:

  • When I run flutter build web --web-renderer canvaskit --release on my local machine, the build/web directory includes:
    • The assets directory (with all required assets).
    • The .env file (copied manually after the build).
    • canvaskit foder
    • and other files

What Doesn't Work on Bitbucket:

  • The assets directory and .env file are missing from the build/web directory after the build step on the Bitbucket server, leading to incomplete deployment.

 

 

Troubleshooting Steps Taken:

  • I’ve added a step to manually create the build/web/assets directory before copying the .env file:

 

- mkdir -p build/web/assets

- cp  /env/.env.dev build/web/.env

 

 

  • I’ve tried listing the contents of the build/web directory after the build step, but the necessary files and folders are still missing.
  • I’ve considered potential differences between my local environment and the Bitbucket Docker environment, but I’m not sure what might be causing the inconsistency.

Questions:

  1. Is there any known issue with the instrumentisto/flutter:latest Docker image that could cause certain files (like the assets directory) to be excluded from the build output?
  2. Could there be a permission issue or a file system limitation on Bitbucket Pipelines that is preventing the .env file and assets directory from being copied or generated properly?
  3. Is there a specific configuration I need to modify in the pipeline to ensure the build/web directory mirrors my local build output exactly?

 

Output when run build command on local device 

assets,canvaskit,icons,js_lib,.last_build_id,crypto_utils,favicon,flutter,flutter_bootstrap,flutter_service_worker,index.html,main.dart,manifest.json,version.json

Output when run build command on bitbucket 

index.html,jcrypto_utils,faveicon,icons,js_lib,manifest.json

Any insights or suggestions would be greatly appreciated!

Thanks!

 

2 answers

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 6, 2024

Hi Mohammad,

You list 6 Key Pipeline Steps. Are these separate steps defined as such in your bitbucket-pipelines.yml file?

For builds running on Atlassian's infrastructure or with a Linux Docker self-hosted runner, each step runs on a separate Docker container. For every step of your build, a Docker container starts using the image you have specified in your bitbucket-pipelines.yml file. The repo is cloned in the build container, and then the commands of the step's script are executed. When the step finishes that Docker container gets destroyed. The same process is repeated for subsequent steps.

Files you generate during one step are not available in subsequent steps, unless you define them as artifacts in your bitbucket-pipelines.yml file:

So, if your build step generates certain files and folders, you'll need to define them as artifacts so that they are available to next steps. Additionally, try running the command that lists the contents of the web folder in the same step where you run the flutter build web command, to check what files and folders are generated right after the command runs.

A few notes also regarding your steps:

  • It doesn't make a lot of sense to have a separate step for 4. and 5. This is similar to spinning up a virtual machine for the sole purpose of copying a file or running an ls command.

  • The same might be true for steps 1 and 2. If steps 1 and 2 pull dependencies you need in order to build and do nothing else, it might make more sense to perform these tasks in the build step, number 3.

Please feel free to reach out if you have any questions!

Kind regards,
Theodora

Mohammad September 6, 2024

@Theodora Boudale  , 

thx very much now i know where my problem and i fixed it 😁❤

Like Theodora Boudale likes this
Mohammad September 6, 2024

@Theodora Boudale  ,

On my local machine, the build output folder contains the assets and canvaskit directories, along with other files. However, when I run ls -la web on the Bitbucket server during the pipeline step, the output does not match and fails to show these files and directories. As a result, when proceeding to the upload step, I cannot find all the required files, which is causing the site not to start.

 

Build Flutter Web Application

 

I have reached #91 bitbucket_build_number so far nothing is complete although the pipes are being completed properly. 😩

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 2024

It's good to hear that the issue is fixed, Mohammad! Please feel free to reach out if you ever need anything else!

Like Mohammad likes this
0 votes
Mohammad September 4, 2024

.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events