Jenkinsfile 3.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
pipeline {
  agent any
  environment {
    GITLAB_API_TOKEN = credentials('GitLabToken')
    COMPOSE_PROJECT_NAME = "${env.JOB_NAME}-${env.BUILD_ID}"
  }
  stages {
    stage('Static Analysis') {
      agent {
        docker { image 'gitlab.rc.uab.edu:4567/center-for-computational-genomics-and-data-science/utility-images/static-analysis:v0.6'}
      }
      steps {
        wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
          sh '/bin/linting.sh'
        }
      }
      post {
        success {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=success&name=jenkins_static_analysis\""
        }
        failure {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=failed&name=jenkins_static_analysis\""
        }
      }
    }
    stage('build') {
      steps {
        sh 'docker-compose -f docker-compose.production.yml build moo-production'
      }
      post {
        success {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=success&name=jenkins_system_tests\""
        }
        failure {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=failed&name=jenkins_system_tests\""
        }
      }
    }
    stage('Publish Updates') {
      when { branch 'master' }
      steps {
        // note -- using `weborg` until we have CGDS @TODO swap out
        sh 'docker login gitlab.rc.uab.edu:4567 -u weborg -p ${GITLAB_API_TOKEN}'
        sh 'docker-compose -f docker-compose.production.yml push'
      }
      post {
        success {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=success&name=updates_published\""
        }
        failure {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=failed&name=updates_published\""
        }
      }
    }
    stage('swarm deploy') {
      when { branch 'master' }
      steps {
        sh 'docker stack deploy --prune --with-registry-auth --compose-file docker-compose.production.yml moo-prod'
      }
      post {
        success {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=success&name=swarm_deployed\""
        }
        failure {
          sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=failed&name=swarm_deployed\""
        }
      }
    }
  }
  post {
    success {
      sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=success&name=jenkins\""
    }
    failure {
      sh "curl --request POST --header \"PRIVATE-TOKEN: ${GITLAB_API_TOKEN}\" \"https://gitlab.rc.uab.edu/api/v4/projects/1014/statuses/${GIT_COMMIT}?state=failed&name=jenkins\""
    }
  }
}