Dropcat setup with Jenkins

Jenkins - simple setup

Example of a drupal 8 setup.

This goes into a build shell:

export DROPCAT_ENV=stage
export ENV=stage
export BUILD_DATE="$(date +"%Y%m%d")"
export BACKUP_NAME=${BUILD_ID}_${BUILD_DATE}.sql
export DB_DUMP_PATH=/backup/${JOB_NAME}/${BACKUP_NAME}

composer install -n --no-dev

dropcat prepare
dropcat tar --folder=${WORKSPACE}
dropcat upload
dropcat move
dropcat update

So a normal build uses 5 commands, prepare, tar, upload, move and update.

The export variables is used inside dropcat, except the ENV variable - that is used in the composer installl. We variables are not needed - dropcat have defaults too handle this - but because we are using Jenkins to handle our builds - we use what we get from Jenkins to get the semantics correct - the site release get the build number and build time from Jenkins, which makes a lot of sense.

The DROPCAT_ENV is deceiding which drocat.DROPCAT_ENV.yml to use - for this example it is the drocat.stage.yml, that is placed inside the .dropcat folder in the root of the gitrepo.

Example of a minimal dropcat.*.yml file

app_name: mysite
local:
  environment:
    drush_folder: /var/lib/jenkins/.drush
remote:
  environment:
    server: some.server.com
    ssh_user: myuser
    ssh_port: 3022
    target_path: /var/www/webroot
    identity_file: /credentials/.ssh/id_rsa
    web_root: /var/www/webroot
    alias: mysite_latest_stage
site:
  environment:
    drush_alias: mysite
    backup_path: /backup
    config_name: sync
    url: http://mysite.some.server.com
    name: mysite
    profile: minimal
mysql:
  environment:
    host: mysql.at.some.server.com
    database: drupal
    user: foobar
    password: secretpassword!
    port: 3306
deploy:
  ignore:
    - .git
    - MAINTAINERS.txt
    - UPDATE.txt
    - README.md
tracker:
  dir: /var/lib/jenkins/trackerdir

Jenkins - setup with config split

Config split is a great module to use if you have configutration differences between development, stage and/or production environments. Or if you have a multi site setup - where sites have configuration differences.

For using config split you only need to add the option config-split-settings to the update command, with the name/names of config split export used, like:

dropcat update --config-split-settings=stage