Compare commits

...

23 Commits

Author SHA1 Message Date
Nicolas Arenas 5801cec5a3 Test to copy report back to jenkins
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 08:47:20 +02:00
Nicolas Arenas d38e99d7eb Adjust report directory
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 08:31:25 +02:00
Nicolas Arenas bb22d5b421 Create report directory
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 08:21:31 +02:00
Nicolas Arenas f9c4da875e Create report directory 2024-10-23 08:21:07 +02:00
Nicolas Arenas e8fd9e6472 Generate stuff report before tests
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 08:17:28 +02:00
Nicolas Arenas 2aabf5b188 Delete and post
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 01:35:28 +02:00
Nicolas Arenas 85a8ad86c6 Running test
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 01:27:04 +02:00
Nicolas Arenas 8ecf148ca6 Running Tests
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 01:25:14 +02:00
Nicolas Arenas ca5b33fe25 Fix
testing/ogcore-api/pipeline/head This commit looks good Details
2024-10-23 01:20:42 +02:00
Nicolas Arenas 7a31acd93d Updated path
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 01:15:48 +02:00
Nicolas Arenas 3e8cdbb86e Step 4
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 01:08:14 +02:00
Nicolas Arenas d5a93b9cfe Install deps
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 01:03:07 +02:00
Nicolas Arenas dab09640a0 Adds running steps
testing/ogcore-api/pipeline/head This commit looks good Details
2024-10-23 01:01:43 +02:00
Nicolas Arenas 600f990020 Test
testing/ogcore-api/pipeline/head This commit looks good Details
2024-10-23 00:56:16 +02:00
Nicolas Arenas cf2844676c Explicit checkout
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:54:53 +02:00
Nicolas Arenas 6c8af6825e Step 1
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:53:48 +02:00
Nicolas Arenas 8bda2bbde5 Try comment out post condition
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:51:27 +02:00
Nicolas Arenas 82c61a8caf Fix to push imagws
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:49:49 +02:00
Nicolas Arenas b0ec7ee6f0 Fix
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:44:38 +02:00
Nicolas Arenas 0280923633 Xunit back to node
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:40:08 +02:00
Nicolas Arenas b1c59266e3 Miniaml changes
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:35:45 +02:00
Nicolas Arenas adce8f4d24 Fix typo
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:29:23 +02:00
Nicolas Arenas 202b29ea6a Modify Jenkinsfile to publish images
testing/ogcore-api/pipeline/head There was a failure building this commit Details
2024-10-23 00:27:52 +02:00
2 changed files with 115 additions and 16 deletions

78
Jenkinsfile vendored
View File

@ -1,46 +1,92 @@
pipeline {
agent {
node {
label 'jenkins-slave'
}
}
environment {
DOCKER_REPO = "opengnsys"
DOCKER_CREDENTIALS = credentials('docker-hub-credentials')
DOCKER_TAG = "${env.BUILD_NUMBER}"
DOCKER_IMAGE_NAME = "ogcore"
BRANCH_NAME = "${env.BRANCH_NAME}"
DOCKER_IDENTITY = "${DOCKER_REPO}/${DOCKER_IMAGE_NAME}-php:${BRANCH_NAME}-${DOCKER_TAG}"
DOCKER_IDENTITY_NGINX = "${DOCKER_REPO}/${DOCKER_IMAGE_NAME}-nginx:${BRANCH_NAME}-${DOCKER_TAG}"
DOCKER_COMPOSE_TEMPLATE = 'docker-compose-ci-template.yaml'
DOCKER_COMPOSE_FILE = 'docker-compose-ci-tmp.yaml'
}
stages {
stage('Build Environmen') {
stage ("Checkout") {
steps {
//Build environment
sh 'docker compose -f docker-compose-ci.yaml up --build -d'
checkout scm
}
}
stage('Build Environment') {
steps {
script {
docker.build("${DOCKER_IDENTITY}", '-f docker/Dockerfile-jenkins-php .')
docker.build("${DOCKER_IDENTITY_NGINX}", '-f docker/Dockerfile-nginx .')
}
}
}
stage(('Prepare Docker Composer')) {
steps {
sh """
sed 's|ogcore-php:static|${DOCKER_IDENTITY}|g; s|ogcore-nginx:static|${DOCKER_IDENTITY_NGINX}|g' ${DOCKER_COMPOSE_TEMPLATE} > ${DOCKER_COMPOSE_FILE}
cat ${DOCKER_COMPOSE_FILE}
"""
}
}
stage('Run containers') {
steps {
sh "docker compose -f ${DOCKER_COMPOSE_FILE} up -d"
}
}
stage('Install dependencies') {
steps {
// Install dependencies
sh 'docker exec ogcore-php composer install'
sh 'docker exec ogcore-php php bin/console lexik:jwt:generate-keypair --overwrite'
sh 'docker exec ogcore-php php bin/console doctrine:migrations:migrate --no-interaction'
sh 'docker exec ogcore-php php bin/console doctrine:fixtures:load --no-interaction'
// Create report directory
sh 'docker exec ogcore-php mkdir -p /report'
sh """
docker compose exec php mkdir -p /report
docker compose exec php composer install
docker compose exec php php bin/console lexik:jwt:generate-keypair --overwrite
docker compose exec php php bin/console doctrine:migrations:migrate --no-interaction
docker compose exec php php bin/console doctrine:fixtures:load --no-interaction
"""
}
}
stage('Tests') {
steps {
// Run tests
sh 'docker compose exec php bin/phpunit --log-junit /report/phpunit.xml'
sh 'docker cp ogcore-php:/report/phpunit.xml .'
sh """
docker compose exec php bin/phpunit --log-junit /report/phpunit.xml
"""
}
}
}
stage ("Publish Image") {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS}") {
docker.image("${DOCKER_IDENTITY}").push()
docker.image("${DOCKER_IDENTITY_NGINX}").push()
}
}
}
}
}
post {
always {
sh "docker compose -f ${DOCKER_COMPOSE_FILE} cp php:/report/phpunit.xml phpunit.xml"
// Publish JUnit test results
xunit (
thresholds: [ skipped(failureThreshold: '0') , failed(failureThreshold: '0') ],
tools: [ PHPUnit(pattern: 'phpunit.xml') ]
)
// Remove containers
sh 'docker compose -f docker-compose-ci.yaml down'
sh 'docker compose -f docker-compose-ci.yaml rm -f'
sh "docker compose -f ${DOCKER_COMPOSE_FILE} down"
sh "docker compose -f ${DOCKER_COMPOSE_FILE} rm -f"
sh "docker rmi ${DOCKER_IDENTITY}"
sh "docker rmi ${DOCKER_IDENTITY_NGINX}"
}
}
}

View File

@ -0,0 +1,53 @@
services:
database:
container_name: ogcore-database
image: mariadb:10.11
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ogcore
MYSQL_PASSWORD: root
MYSQL_USER: admin
ports:
- 3336:3306
volumes:
- database_data:/var/lib/mysql
networks:
- ogcore-network
nginx:
container_name: ogcore-nginx
build:
context: .
dockerfile: ./docker/Dockerfile-nginx
depends_on:
- php
ports:
- 8080:80
volumes:
- ./public:/var/www/html/public:cached
networks:
- ogcore-network
image: ogcore-nginx:static
php:
container_name: ogcore-php
build:
context: .
dockerfile: ./docker/Dockerfile-jenkins-php
depends_on:
- database
environment:
XDEBUG_CLIENT_HOST: 127.17.0.1
XDEBUG_CLIENT_PORT: 9003
PHP_IDE_CONFIG: serverName=ogcore
networks:
- ogcore-network
image: ogcore-php:static
volumes:
- ./report:/root/
volumes:
database_data:
networks:
ogcore-network: