ademain
(Axel)
October 31, 2022, 2:32pm
1
Hi,
I just finished to write my droneci.yml scenario. When running locally “drone exec --pipeline testing”, it’s a success until the end. I added a trigger on pull_request or pull on master.
First question, the build doesn’t trigger automatically when I merge a pull request. I must start it manually.
Second question : on the build progress page, it jumps straight to the deployment stage.
If I remove the deployment stage, when running a build, the pipeline stages show only testing. But nothing happens at all. I can wait hour, the black console keep showing loading…
I probably didn’t understand how to create a scenario where I test my app, and run a deployment if all the tests are OK.
Thanks in advance
Here is my config :
---
###########
# TESTING #
###########
kind: pipeline
type: docker
name: testing
platform:
os: linux
arch: amd64
workspace:
path: /drone/src
services:
- name: mariadb
image: mariadb:10.5.17
environment:
MARIADB_DATABASE: laplace_test
MARIADB_ROOT_PASSWORD: password
- name: memcached
image: memcached:bullseye
steps:
- name: frontend
pull: if-not-exists
image: node:16.18-bullseye-slim
commands:
- node -v
- npm -v
- yarn --version
- yarn config set cache-folder .yarn-cache
- yarn install
- yarn run production
- name: backend
pull: if-not-exists
image: php:8.1.12-cli-bullseye
depends_on:
- mariadb
- memcached
commands:
- apt-get -q update && apt-get -q -y install -y libxml2-dev libzip-dev libpng-dev libonig-dev libmemcached-dev build-essential libssl-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev mariadb-client
- docker-php-ext-install pdo
- docker-php-ext-install pdo_mysql
- docker-php-ext-configure gd --with-jpeg && docker-php-ext-install gd && docker-php-ext-enable gd
- docker-php-ext-install mysqli && docker-php-ext-enable mysqli
- docker-php-ext-install zip
- docker-php-ext-install xml
- docker-php-ext-install bcmath
- pecl install memcached && docker-php-ext-enable memcached
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- php composer.phar install --prefer-dist
- php artisan test
trigger:
branch:
- master
event:
- push
- pull_request
---
kind: signature
hmac: 3d94e4b5b9d162b020a610a09359246da7b6f5b172051aec90841acfd3ed5a8e
---
##############
# DEPLOYMENT #
##############
kind: pipeline
type: ssh
name: deployment
server:
host: box.web.fr
user: deployer
password:
from_secret: ssh_key
steps:
- name: greeting
commands:
- echo hello world
trigger:
branches:
- master
event:
- promote
jimsheldon
(Jim Sheldon)
October 31, 2022, 4:48pm
2
You mention droneci.yml, do you mean .drone.yml? Drone looks for .drone.yml by default.
Are you running both a docker runner and the ssh runner? Have you verified that both have successfully connected to the drone server by viewing the logs?
You say:
I probably didn’t understand how to create a scenario where I test my app, and run a deployment if all the tests are OK.
This is definitely possible with drone, we can help you make it happen.
See the Graph Execution example in the documentation. You will need to add a depends_on
rule parameter to the deployment
stage like this:
depends_on
- testing
As far as the pipeline not triggering on pull requests, have you checked the webhook deliveries for your repository for any errors?
ademain
(Axel)
October 31, 2022, 4:58pm
3
Hello @jimsheldon thanks, yes sorry I mean .drone.yml
About the webhooks, good point. Domain name configuration issue on my side, will be fixed soon.
About the Graph execution, thanks for the link.
Now builds don’t even start manually. When I look in the logs, I have :
axel@Macbook-Axel drone log view webinno/laplacecoworking
2022/10/31 17:54:34 proto: duplicate proto type registered: PluginSpec
2022/10/31 17:54:34 proto: duplicate proto type registered: PluginPrivilege
strconv.Atoi: parsing "": invalid syntax
Running locally doesn’t show any parsing error, but doesn’t work on the server.
Here is my updated config file:
---
###########
# TESTING #
###########
kind: pipeline
type: docker
name: testing
platform:
os: linux
arch: amd64
workspace:
path: /drone/src
services:
- name: mariadb
image: mariadb:10.5.17
environment:
MARIADB_DATABASE: laplace_test
MARIADB_ROOT_PASSWORD: password
- name: memcached
image: memcached:bullseye
steps:
- name: frontend
pull: if-not-exists
image: node:16.18-bullseye-slim
commands:
- node -v
- npm -v
- yarn --version
- yarn config set cache-folder .yarn-cache
- yarn install
- yarn run production
- name: backend
pull: if-not-exists
image: php:8.1.12-cli-bullseye
depends_on:
- mariadb
- memcached
commands:
- apt-get -q update && apt-get -q -y install -y libxml2-dev libzip-dev libpng-dev libonig-dev libmemcached-dev build-essential libssl-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev mariadb-client
- docker-php-ext-install pdo
- docker-php-ext-install pdo_mysql
- docker-php-ext-configure gd --with-jpeg && docker-php-ext-install gd && docker-php-ext-enable gd
- docker-php-ext-install mysqli && docker-php-ext-enable mysqli
- docker-php-ext-install zip
- docker-php-ext-install xml
- docker-php-ext-install bcmath
- pecl install memcached && docker-php-ext-enable memcached
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- php composer.phar install --prefer-dist
- php artisan test
trigger:
branch:
- master
event:
- push
- pull_request
---
##############
# DEPLOYMENT #
##############
kind: pipeline
type: ssh
name: deployment
depends_on:
- testing
server:
host: box.web.fr
user: deployer
password:
from_secret: ssh_key
steps:
- name: greeting
commands:
- echo hello world
trigger:
branches:
- master
event:
- promote
---
kind: signature
hmac: d961684b3a5c830dfda2da39cf56d3f087e922dbce1e23fae8361a07d0375422
...
ademain
(Axel)
November 1, 2022, 10:20am
4
Hello again,
I fixed the webhook, it’s working now. Just did a push on master, it triggered a build.
But it still shows the following screen:
Then it stucks, at least it doesn’t output any log message.
I don’t get why it’s working locally with drone exec --pipeline testing
.
ademain
(Axel)
November 1, 2022, 11:56am
5
OK guys, sorry, this was dumb. I didn’t realize the runner wasn’t working fine because of a configuration error. I did a docker logs runner
to figure this out.
Thanks
1 Like