Skip to main content

How to add automatic nightly builds to your Nextcloud app

2 min read

For two years Portknox has been hosting the nightly builds for several Nextcloud apps. As we have to move to a newer server, I'll take the chance to document the nightly creation process. So, if you want to add nightly builds to your app here is a full automated and low-maintenance process. In case you need help or a place to save the builds just send us an email. We are happy to help!

.travis.yml

 env:
     global:
        - NIGHTLY=FALSE
script:
- if [[ "$NIGHTLY" = "TRUE" ]]; then curl --ftp-create-dirs -T /home/travis/build/nextcloud/core/apps/contacts/build/artifacts/appstore/calendar.tar.gz -u $FTP_LOGIN:$FTP_PW ftp://upload.portknox.de/htdocs/calendar/nextcloud_calendar_nightly_build_$(date +%Y-%m-%d).tar.gz; fi

Cron Job on the nightly server:

build_calendar_nightly.sh

#!/bin/sh
DATA="/home/ftp/calendar" 
ARCHIVE="$DATA/archive" 

# create structure
mkdir -p $ARCHIVE

# move directories in the current directory older than 14 days to archive
find $DATA -maxdepth 1 -type d -mtime +14 -exec mv {} $ARCHIVE \;

# delete data in archive
find $ARCHIVE -type d -mtime +90 -exec rm -rf {} \;

# Prepare curl request
body='{ "request": { "message": "Nightly build", "branch":"master", "config": { "env": { "matrix": ["DB=sqlite CORE_BRANCH=master TEST_JS=FALSE PHP_COVERAGE=FALSE PACKAGE=TRUE NIGHTLY=TRUE"] }, "php": ["7"], "matrix": { "fast_finish": false } } }}'
# Trigger nightly build curl -s -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "Travis-API-Version: 3" \ -H "Authorization: token <Insert token>" \ -d "$body" \ https://api.travis-ci.org/repo/nextcloud%2Fcalendar/requests


Here are the related pull requests forĀ Calendar and Contacts.