Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make jenkins service optional for Spryker harness #377

Merged
merged 4 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_base/harness/config/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
command('app build'):
env:
HAS_CRON: "= ('cron' in @('app.services') ? 'true' : 'false')"
HAS_JENKINS_RUNNER: "= ('jenkins-runner' in @('app.services') ? 'true' : 'false')"
exec: |
#!bash(workspace:/)|@
ws external-images pull
Expand All @@ -12,6 +13,9 @@ command('app build'):
if [[ "${HAS_CRON}" == "true" ]]; then
passthru docker-compose build cron
fi
if [[ "${HAS_JENKINS_RUNNER}" == "true" ]]; then
passthru docker-compose build jenkins-runner
fi

command('app build <service>'):
env:
Expand Down
15 changes: 8 additions & 7 deletions src/_base/harness/scripts/enable.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ dynamic()

ws external-images pull

passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | xargs docker-compose build"

{% if ("cron" in @('app.services')) %}
passthru "docker-compose config --services | grep -v cron | xargs docker-compose build"
passthru docker-compose build cron
# Bring up all but cron
passthru "docker-compose config --services | grep -v cron | xargs docker-compose up -d"
{% else %}
passthru docker-compose build
# Bring up all services
passthru docker-compose up -d
{% endif %}
{% if ("jenkins-runner" in @('app.services')) %}
passthru docker-compose build jenkins-runner
{% endif %}

# Bring up all services apart from cron and jenkins-runner
passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | xargs docker-compose up -d"

passthru docker-compose exec -T -u build console app build
passthru docker-compose exec -T -u build console app init
Expand Down
12 changes: 12 additions & 0 deletions src/spryker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ git commit -m "Initial commit"
```
6. Store the `workspace.override.yml` contents in a suitable location (such as LastPass).

To enable jenkins service for running Spryker's background jobs, set following config in workspace.yml:
```yaml
attribute('app.services'):
- chrome
- postgres
- redis
- elasticsearch
- rabbitmq
- jenkins
- jenkins-runner
```

[Workspace]: https://github.com/my127/workspace
20 changes: 12 additions & 8 deletions src/spryker/application/skeleton/config/Shared/config_local.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,18 @@
$config[RabbitMqEnv::RABBITMQ_CONNECTIONS][$CURRENT_STORE][RabbitMqEnv::RABBITMQ_DEFAULT_CONNECTION] = true;

// ---------- Scheduler
$config[SchedulerConstants::ENABLED_SCHEDULERS] = [
SchedulerConfig::SCHEDULER_JENKINS,
];
$config[SchedulerJenkinsConstants::JENKINS_CONFIGURATION] = [
SchedulerConfig::SCHEDULER_JENKINS => [
SchedulerJenkinsConfig::SCHEDULER_JENKINS_BASE_URL => 'http://' . getenv('JENKINS_HOST') . ':' . getenv('JENKINS_PORT') . '/',
],
];
$config[SchedulerConstants::ENABLED_SCHEDULERS] = [];

if (getenv('HAS_JENKINS_RUNNER') === 'true') {
$config[SchedulerConstants::ENABLED_SCHEDULERS] = [
SchedulerConfig::SCHEDULER_JENKINS,
];
$config[SchedulerJenkinsConstants::JENKINS_CONFIGURATION] = [
SchedulerConfig::SCHEDULER_JENKINS => [
SchedulerJenkinsConfig::SCHEDULER_JENKINS_BASE_URL => 'http://' . getenv('JENKINS_HOST') . ':' . getenv('JENKINS_PORT') . '/',
],
];
}

// ---------- Mail configuration
$config[MailConstants::SMTP_HOST] = getenv('SMTP_HOST');
Expand Down
10 changes: 5 additions & 5 deletions src/spryker/application/skeleton/config/install/docker.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ sections:
generate-ide-auto-completion:
command: "if [ \"$APPLICATION_ENV\" = \"development\" ]; then vendor/bin/console dev:ide:generate-auto-completion; fi"

jenkins-down:
jenkins-stop:
scheduler-down:
scheduler-stop:
command: "vendor/bin/console scheduler:clean"
stores: true

Expand Down Expand Up @@ -226,12 +226,12 @@ sections:
- AT
- US

jenkins-up:
jenkins-generate:
scheduler-up:
scheduler-generate:
command: "vendor/bin/console scheduler:setup"
stores: true

jenkins-enable:
scheduler-enable:
command: "vendor/bin/console scheduler:resume"
stores: true

Expand Down
4 changes: 2 additions & 2 deletions src/spryker/harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ attributes:
install:
steps:
- task rabbitmq:vhosts
- task http:wait "$JENKINS_URL"
- "= (('jenkins' in @('app.services')) ? 'task http:wait $JENKINS_URL' : '')"
- task spryker:install
- task overlay:apply
init:
steps:
- task http:wait "$JENKINS_URL"
- "= (('jenkins' in @('app.services')) ? 'task http:wait $JENKINS_URL' : '')"
- task rabbitmq:vhosts
- task spryker:init
migrate:
Expand Down
1 change: 1 addition & 0 deletions src/spryker/harness/attributes/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ attributes:
REDIS_PROTOCOL: = @('redis.protocol')
SMTP_HOST: = @('smtp.host')
SMTP_PORT: = @('smtp.port')
HAS_JENKINS_RUNNER: "= ('jenkins-runner' in @('app.services') ? 'true' : 'false')"
JENKINS_HOST: = @('jenkins.host')
JENKINS_PORT: = @('jenkins.port')
JENKINS_URL: = 'http://' ~ @('jenkins.host') ~ ':' ~ @('jenkins.port') ~ '/'
Expand Down
7 changes: 0 additions & 7 deletions src/spryker/harness/config/spryker-pipeline.yml

This file was deleted.

80 changes: 0 additions & 80 deletions src/spryker/harness/scripts/enable.sh.twig

This file was deleted.