Commit a7a0d7905475bec1e7053f17fcadc7c86cb190b2

Authored by George Vlahavas
1 parent 1f3a6f168e

Add initial Jenkins pipeline

Showing 1 changed file with 74 additions and 0 deletions

kea_testing.groovy View file @ a7a0d79
  1 +/**
  2 +* Jenkinsfile to deploy multiple Docker containers based on docker-compose into a DEV server and run any test.
  3 +* This pipeline will run the Docker containers, execute the tests and then stop and remove the containers from the DEV
  4 +* server automatically.
  5 +**/
  6 +
  7 +
  8 +pipeline {
  9 +
  10 + agent any
  11 +
  12 + environment {
  13 +
  14 + // Keep as is the following two lines
  15 + PRIVATE_REGISTRY = "https://registry.curex-project.eu:443/curex-local/"
  16 + ARTIFACTORY_URL = "registry.curex-project.eu:443/curex-local/"
  17 +
  18 + DEPLOYMENT_HOST = "116.203.166.220:2376"
  19 + DEPLOYMENT_HOST_CREDENTIALS = "vm2-creds"
  20 + }
  21 +
  22 + stages {
  23 +
  24 + stage('Checkout the source code') {
  25 + steps {
  26 + checkout scm
  27 + }
  28 + }
  29 +
  30 +
  31 + stage('Deploy Docker containers in DEV server') {
  32 + steps {
  33 + script {
  34 + docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") {
  35 + docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') {
  36 +
  37 + echo 'Deploying the specified Docker containers in DEV server'
  38 + sh 'sh deploy.sh'
  39 +
  40 + }
  41 + }
  42 + }
  43 + }
  44 + }
  45 +
  46 + stage('Run tests') {
  47 + steps {
  48 + script {
  49 +
  50 + echo 'Run any necessary test'
  51 + /* Here do your tests */
  52 +
  53 + }
  54 + }
  55 + }
  56 +
  57 +
  58 + stage('Stop and remove the Docker containers in DEV server') {
  59 + steps {
  60 + script {
  61 + docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") {
  62 + docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') {
  63 +
  64 + echo 'Stop and remove the specified Docker containers from the DEV server'
  65 + sh 'sh delete.sh'
  66 +
  67 + }
  68 + }
  69 + }
  70 + }
  71 + }
  72 +
  73 + }
  74 +}