Skip to content

How to create a folder in Tomcat working directory before running test cases with the AWS Blu Age Devops Pipeline ?

0

Hello, For a batch test case, I need a folder to pre-exist in the Tomcat working directory so that files can be created inside during the process. To do that, I manually created the folder on my local machine and it worked fine, so I pushed it to the gitlab repository containing the server configuration and working directory. The issue is that when the pipeline runs, the folder does not exist and an error appears, so it seems that the working directory is not replicated from gitlab but is instead created from scratch everytime.

So my question is : how to make sure that the folder can be created in the tomcat working directory before the test case runs on the CI ?

The current configuration of my server repository is the following, and the folder I need is the home folder :

gitlab-[project_name]-server
    |- some folders
    |- workingDir
        |- config
            |- some files
        |- home
2 Answers
7
Accepted Answer

Hello,

When creating the Tomcat docker image of the modernized application, the CI only takes the workindDir/config and the workingDir/scripts folders of the gitlab-<PROJECT_NAME>-server repository. If you want to modify this behavior, you'll have to modify the gitlab-<PROJECT_NAME>-devops/codebuild/codebuild-app/scripts/init_tomcat_directories.sh file by adding these lines:

mkdir -p ${TOMCAT_DIR}/home
cp -r ${CODEBUILD_SRC_DIR_APP_SERVER_ARTIFACT}/workingDir/home/* ${TOMCAT_DIR}/home

Hope this helps! 😊

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

0

When working with the AWS Blu Age DevOps pipeline for running test cases, creating a folder in the Tomcat working directory requires a different approach than simply pushing it to the CodeCommit repository. The working directory is indeed created from scratch each time the pipeline runs, which explains why your manually created folder doesn't persist.

To ensure that the required folder exists in the Tomcat working directory before your test case runs, you should modify your build or deployment scripts to create the folder programmatically. This can be done as part of your CI/CD pipeline setup.

Here's a general approach you can take:

  1. Modify your build script (e.g., a shell script or a Maven/Gradle task) to include commands that create the necessary folder structure.

  2. Add this script or task to your pipeline configuration, ensuring it runs before your test cases are executed.

  3. Use AWS CodeBuild or the appropriate stage in your pipeline to execute these folder creation commands.

For example, you might add a command like this to your build script:

mkdir -p /path/to/tomcat/workingDir/home

This command will create the 'home' folder (and any necessary parent directories) if it doesn't already exist.

Remember to adjust the paths according to your specific Tomcat configuration and working directory structure.

By incorporating the folder creation into your automated build process, you ensure that the required directory structure is in place every time the pipeline runs, regardless of what's in your CodeCommit repository. This approach aligns with the principles of Infrastructure as Code (IaC) and helps maintain consistency across different environments and pipeline runs.

If you need to include specific files within this folder, consider adding those file creation or copy commands to your build script as well. This way, your entire working directory structure, including any necessary folders and files, will be recreated consistently with each pipeline run.

Sources
Automate the building, testing, and deployment processes of AWS Mainframe Modernization with AWS Blu Age | Migration & Modernization

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.