Hi, I want to setup CI to my project. I have installed Jenkins and Plesk on my server. I have integrated bitbucket to the Build. But don’t know how to write the shell commands to pull the Laravel code from the stage branch. Can you configure it. I will share the IP Address of the server
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello there,
I would suggest that you check out this step by step tutorial on How To Set Up Continuous Integration Pipelines in Jenkins:https:
Hope that this helps!
To set up Continuous Integration (CI) with Jenkins for your Laravel project and pull code from the stage branch of your Bitbucket repository, follow these steps:
https://bitbucket.org/your_username/your_repository.git
Provide your Bitbucket credentials (Jenkins will prompt you to add them).
Specify the branch to build: stage
Scroll to Build and select Execute Shell to add shell commands.
Use the following script as an example. Replace placeholders (like /var/www/your_laravel_project) with your actual Laravel project directory:
#!/bin/bash
# Define variables
DEPLOY_DIR="/var/www/your_laravel_project"
# Ensure the deployment directory exists
if [ ! -d "$DEPLOY_DIR" ]; then
echo "Deployment directory does not exist. Exiting."
exit 1
fi
# Navigate to the deployment directory
cd $DEPLOY_DIR
# Stash local changes, if any
git stash
# Pull the latest changes from the stage branch
git checkout stage
git pull origin stage
# Set proper permissions (optional, adjust based on your server setup)
chown -R www-data:www-data $DEPLOY_DIR
chmod -R 775 $DEPLOY_DIR/storage $DEPLOY_DIR/bootstrap/cache
# Install/update dependencies
composer install --no-dev --optimize-autoloader
# Run database migrations (optional)
php artisan migrate --force
# Clear and cache configurations
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
php artisan view:clear
php artisan view:cache
# Restart queues (if applicable)
php artisan queue:restart
echo "Deployment completed successfully."
http://<JENKINS_SERVER_IP>:8080/bitbucket-hook/stage branch in Bitbucket.Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.