"...java/git@transfer.hft-stuttgart.de:cota/cota-backend.git" did not exist on "d59a136b09925df8eb944adccbeac74c138e25f1"
Commit 79a7359e authored by Abhishek's avatar Abhishek
Browse files

Update .gitlab-ci.yml file

parent 795bb14f
Pipeline #11798 passed with stage
in 9 minutes and 53 seconds
# This GitLab CI/CD pipeline is designed to run the complete Moodle # This GitLab CI/CD pipeline is designed to run the complete Moodle
# automation script in a single, manually triggered job. # automation script in a single, manually triggered job.
# Use the official Docker image to enable Docker-in-Docker (dind).
# This allows us to run docker-compose inside the CI job.
image: docker:20.10.16 image: docker:20.10.16
services: services:
...@@ -13,11 +11,8 @@ stages: ...@@ -13,11 +11,8 @@ stages:
- full_test # A single stage for our end-to-end test. - full_test # A single stage for our end-to-end test.
variables: variables:
# This tells docker-compose how to connect to the Docker-in-Docker service.
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
# This disables TLS, which is often required for dind inside GitLab CI.
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR: ""
# Provides default values for the variables in your docker-compose.yml.
EUSER: "1000" EUSER: "1000"
EGID: "1000" EGID: "1000"
MOODLE_URL: "http://docker:8080" MOODLE_URL: "http://docker:8080"
...@@ -25,40 +20,41 @@ variables: ...@@ -25,40 +20,41 @@ variables:
# This is the URL Moodle's entrypoint script will use for its wwwroot. # This is the URL Moodle's entrypoint script will use for its wwwroot.
MOODLE_WWWROOT: "http://docker:8080" MOODLE_WWWROOT: "http://docker:8080"
run_full_automation: run_full_automation:
stage: full_test stage: full_test
# 'when: manual' means this job will ONLY run when you click the
# "play" button for it in the GitLab CI/CD > Pipelines view.
when: manual when: manual
before_script: before_script:
# Install the necessary tools inside the Docker runner.
- apk add --no-cache curl docker-compose bash jq - apk add --no-cache curl docker-compose bash jq
# A simple loop to wait until the Docker daemon is ready.
- until docker info > /dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 3; done - until docker info > /dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 3; done
script: script:
# 1. Start all the services defined in your docker-compose.yml file.
# The '-d' runs them in the background.
- echo "Starting Docker environment..." - echo "Starting Docker environment..."
- docker-compose up -d - docker-compose up -d
# 2. Wait for the Moodle container to fully initialize and run its entrypoint script. # --- THIS IS THE FIX ---
# This is a simple but effective way to wait for the installation to finish. # Instead of a fixed sleep, we will loop until the Moodle installation is complete.
- echo "Waiting 2 minutes for Moodle to install and start..." # We know it's complete when the config.php file exists.
- sleep 120 - echo "Waiting for Moodle first-time installation to complete..."
- |
# 3. Make your main script executable. timeout=300
# !!! IMPORTANT: Replace 'your_main_script.sh' with the actual filename. !!! while ! docker exec moodle-web-official [ -f /var/www/html/config.php ]; do
timeout=$((timeout - 5))
if [ $timeout -le 0 ]; then
echo "❌ ERROR: Moodle installation timed out after 5 minutes."
docker logs moodle-web-official
exit 1
fi
echo " -> Installation not yet complete, waiting 5 more seconds..."
sleep 5
done
- echo "✅ Moodle installation complete (config.php found)."
# Now that Moodle is stable, we can proceed with the rest of the script.
- chmod +x test-moodle.sh - chmod +x test-moodle.sh
# 4. Run the entire script from top to bottom.
- echo "Executing the main automation script..." - echo "Executing the main automation script..."
- ./test-moodle.sh - ./test-moodle.sh
after_script: after_script:
# It's good practice to clean up the environment after the test.
# The '-v' flag removes the volumes, ensuring the next run is completely clean.
- echo "Tearing down Docker environment..." - echo "Tearing down Docker environment..."
- docker-compose down -v - docker-compose down -v
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment