Step 1
testing/ogcore-api/pipeline/head There was a failure building this commit Details

develop-jenkins
Nicolas Arenas 2024-10-23 00:53:48 +02:00
parent 8bda2bbde5
commit 6c8af6825e
1 changed files with 65 additions and 55 deletions

112
Jenkinsfile vendored
View File

@ -24,63 +24,73 @@ pipeline {
} }
} }
} }
stage(('Prepare Docker Composer')) { stage ("Delete Image") {
steps { steps {
sh """ script {
sed 's|ogcore-php:static|${DOCKER_IDENTITY}|g; s|ogcore-nginx:static|${DOCKER_IDENTITY_NGINX}|g' ${DOCKER_COMPOSE_TEMPLATE} > ${DOCKER_COMPOSE_FILE} sh "docker rmi ${DOCKER_IDENTITY}"
""" sh "docker rmi ${DOCKER_IDENTITY_NGINX}"
}
}
} }
} }
stage('Run containers') { // stage(('Prepare Docker Composer')) {
steps { // steps {
sh "docker compose -f ${DOCKER_COMPOSE_FILE} up -d" // sh """
} // sed 's|ogcore-php:static|${DOCKER_IDENTITY}|g; s|ogcore-nginx:static|${DOCKER_IDENTITY_NGINX}|g' ${DOCKER_COMPOSE_TEMPLATE} > ${DOCKER_COMPOSE_FILE}
} // """
stage('Install dependencies') { // }
steps { // }
// Install dependencies
sh """
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
// Create report directory
docker compose exec php mkdir -p /report
"""
}
}
stage('Tests') { // stage('Run containers') {
steps { // steps {
// Run tests // sh "docker compose -f ${DOCKER_COMPOSE_FILE} up -d"
sh """ // }
docker compose exec php bin/phpunit --log-junit /report/phpunit.xml // }
docker compose cp php:/report/phpunit.xml ./phpunit.xml // stage('Install dependencies') {
""" // steps {
} // // Install dependencies
// sh """
// 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
// // Create report directory
// docker compose exec php mkdir -p /report
// """
// }
// }
// stage('Tests') {
// steps {
// // Run tests
// sh """
// docker compose exec php bin/phpunit --log-junit /report/phpunit.xml
// docker compose cp php:/report/phpunit.xml ./phpunit.xml
// """
// }
// // post {
// // success {
// // script {
// // docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS}") {
// // docker.image("${DOCKER_IDENTITY}").push()
// // docker.image("${DOCKER_IDENTITY_NGINX}").push()
// // }
// // }
// // }
// // }
// }
// }
// post { // post {
// success { // always {
// script { // // Publicar los resultados de las pruebas de PHPUnit
// docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS}") { // xunit (
// docker.image("${DOCKER_IDENTITY}").push() // thresholds: [ skipped(failureThreshold: '0'), failed(failureThreshold: '0') ],
// docker.image("${DOCKER_IDENTITY_NGINX}").push() // tools: [ PHPUnit(pattern: 'phpunit.xml') ]
// } // )
// } // // Remove containers
// sh 'docker compose -f ${DOCKER_COMPOSE_FILE} down'
// sh 'docker compose -f ${DOCKER_COMPOSE_FILE} rm -f'
// } // }
// } // }
} }
}
post {
always {
// Publicar los resultados de las pruebas de PHPUnit
xunit (
thresholds: [ skipped(failureThreshold: '0'), failed(failureThreshold: '0') ],
tools: [ PHPUnit(pattern: 'phpunit.xml') ]
)
// Remove containers
sh 'docker compose -f ${DOCKER_COMPOSE_FILE} down'
sh 'docker compose -f ${DOCKER_COMPOSE_FILE} rm -f'
}
}
}