我正在尝试为GCP托管的网站设置cron作业。我们使用Travis CI构建网站并将其部署到GAE。我创建了一个cron.yaml以运行一些测试,但是我不知道如何将其部署到我们的网站。
这是我的cron.yaml:
cron:
- description: TestPush Notification
url: /test
schedule: every 1 mins
retry_parameters:
min_backoff_seconds: 2.5
max_doublings: 5
timezone: America/Vancouver
这是我的.travis.yaml:
sudo: false
language: python
python:
- '2.7'
before_install:
- openssl aes-256-cbc -K $encrypted_xxxx_key -iv $encrypted_xxxx_iv -in client-secret.json.enc -out client-secret.json -d
- export PYTHONPATH="${PYTHONPATH}:${TRAVIS_BUILD_DIR}/lib"
install:
- pip install -r requirements-prd.txt -t lib/
- pip install requests --upgrade -t lib/
- cd ubyssey/static
- npm install -g gulp
- npm install
script:
- gulp build
after_success:
# clean up node_modules
- rm -rf node_modules
- cd ${TRAVIS_BUILD_DIR}
# use deploy settings
- mv _settings/settings-dpl.py ubyssey/settings.py
- python manage.py collectstatic --noinput
# gzip static files
- find ${TRAVIS_BUILD_DIR}/gcs -type f -exec gzip "{}" \; -exec mv "{}.gz" "{}" \;
# replace deploy settings with production settings
- rm ubyssey/settings.py ubyssey/settings.pyc
- mv _settings/settings-prd.py ubyssey/settings.py
- rm -rf .git/
deploy:
- provider: gcs
access_key_id: <omitted>
secret_access_key:
secure: <omitted>
bucket: ubyssey
skip_cleanup: true
acl: public-read
local-dir: ${TRAVIS_BUILD_DIR}/gcs
detect_encoding: true
cache_control: "max-age=31536000"
on:
tags: true
- provider: gae
keyfile: client-secret.json
project: ubyssey-prd
default: true
version: ubyssey-${TRAVIS_TAG//./-} # Replace periods with hyphens
skip_cleanup: true
on:
tags: true
我如何获得travis版本以使用cron.yaml部署应用程序?
答案 0 :(得分:1)
看起来travis使用gcloud app deploy app.yaml
https://docs.travis-ci.com/user/deployment/google-app-engine/#Other-Available-Configuration-Options
因此,您需要travis来显式添加cron.yaml,例如gcloud app deploy app.yaml cron.yaml
https://cloud.google.com/appengine/docs/flexible/go/scheduling-jobs-with-cron-yaml
It's hard to tell if travis's config lets you specify multiple deployables
您可能需要添加一个重复的provider: gae
条目,其中config
指向您的cron.yaml