Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

need CI/CD only specific subfolders instead of full repository

i am new to CI/CD.

in my staging/UAT server, we are having static configuration files/folder with a different database configuration that is added in .gitignore.

but in repository configuration, we are having production configuration.

when I tried CI/CD its building, it builds a whole repository and deployed it in a staging server with production configuration.

my project folder structure is:

Root Folder:
      -> src (folder)
      -> CDN(css/js - folder)
      -> config (folder)

here I don't want to replace the config folder for every CI/CD.

Please help me how can I achieve this.

my staging deployment step:


- step:
     name: 'Deployment to Staging'
     deployment: staging
         - echo "Your deployment to staging script goes here..."
         - apt-get update
         - apt-get install -y zip
         - zip -r .
         - pipe: atlassian/aws-code-deploy:0.2.5
             S3_BUCKET: $AWS_S3_BUCKET
             LOCAL_PATH: 'src'
             COMMAND: 'upload'
             ZIP_FILE: ''
             VERSION_LABEL: 'my-app-3.0.0'
         - pipe: atlassian/aws-code-deploy:0.2.5
              S3_BUCKET: $AWS_S3_BUCKET
              COMMAND: 'deploy'
              WAIT: 'true'
              VERSION_LABEL: 'my-app-3.0.0'

2 answers

1 accepted

0 votes
Answer accepted

Hi @Sivanandh,

Please allow me to give some context first. When you run a Pipelines build, then for each step of this build:
- a Docker container starts
- the repo is cloned in the directory /opt/atlassian/pipelines/agent/build, which is the base directory of the build
- then the commands in the script of this step (from the yml file) are executed

If your repo has the following directories at its root:
- src
- config

then these directories will get cloned in the base directory of the build. During the build, you should be able to change directories with a cd command and execute commands in that specific directory.

For the specific issue you are reporting here, you mention that you don't want the whole repo deployed to the staging server.
Based on the part of the yaml file that you included in your post, I can see you are using a pipe to deploy, and you are deploying the file

This file is generated by the previous command in your script, which is

zip -r .

The dot in that command specifies that the zip should include all the files/directories from the current directory.

If you don't want the config folder to be included in the zip, but only the other 2 folders, you can specify this in the command, e.g. like below:

zip -r src CDN

Please feel free to let me know if this helps and if you have any questions.

Kind regards,

Hello @Theodora Boudale 

Tnx for your response, your suggestion works fine.

But I want to keep static config files and folders on my server

zip -r src CDN

but the above command is removed all other files from the staging server.  I don't want to remove the config/vendor folder.

and after I added the above command, I have to create appspec.yml in src, CDN folder, am I correct? please correct me I am wrong.

can I keep the config & vendor folder in the root folder without any build process from CI/CD

can I implement ci/cd only for the src & CDN folder,? I want to keep all other folders in my root folder without ci/cd
is it possible to achieve this?

Hi @Sivanandh,

Thank you for your reply.

First, allow me to say that I am not very familiar with CodeDeploy, so the help I can provide with details of a solution is limited. After doing some search, I found that it may be standard behavior from CodDeploy to delete all existing files and replace them with the deployment package:

During the deployment process, CodeDeploy deletes all the files that are part of the previous successful deployment.

Considering that, some ideas to work around this issue:

1) Commit the config directory of the staging server to the repo, and include it in the zip you create for deployment.
Is that a possibility for you?

2) If you don't want to or cannot commit the staging server's config directory in the repo, then would the following be an option?

during the step 'Deployment to Staging'
- delete the config directory that is already there (since it's the production server's config)
- copy the staging server's config from EC2 (e.g. with scp if that's possible)
- then include it in the zip you create for deployment.

3) I also found the following thread in StackOverflow where a similar issue is discussed, and the answer there mentions a way to configure CodeDeploy so that files are retained:

Kind regards,

Like Sivanandh likes this

Understood. Thanks @Theodora Boudale .

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

106 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you