Jenkinsfile 2.8 KB
Newer Older
1
2
3
/*
** Variables.
*/
4
def serie = '20.10'
5
6
7
8
9
10
11
12
13
14
15
16
def maintenanceBranch = "${serie}.x"
if (env.BRANCH_NAME.startsWith('release-')) {
  env.BUILD = 'RELEASE'
} else if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == maintenanceBranch)) {
  env.BUILD = 'REFERENCE'
} else {
  env.BUILD = 'CI'
}

/*
** Pipeline code.
*/
17
18
19
20
21
22
stage('Source') {
  node {
    sh 'setup_centreon_build.sh'
    dir('centreon-connector') {
      checkout scm
    }
23
    sh "./centreon-build/jobs/connector/${serie}/mon-connector-source.sh"
24
    source = readProperties file: 'source.properties'
25
26
27
28
29
30
31
32
    publishHTML([
      allowMissing: false,
      keepAll: true,
      reportDir: 'summary',
      reportFiles: 'index.html',
      reportName: 'Centreon Connector Build Artifacts',
      reportTitles: ''
    ])
33
34
35
36
37
38
39
40
    env.VERSION = "${source.VERSION}"
    env.RELEASE = "${source.RELEASE}"
  }
}

try {
  stage('Unit tests') {
    parallel 'centos7': {
41
      node {
42
        sh 'setup_centreon_build.sh'
43
/*
44
        sh './centreon-build/jobs/connector/${serie}/mon-connector-unittest.sh centos7'
45
46
47
48
49
50
51
52
        step([
          $class: 'XUnitBuilder',
          thresholds: [
            [$class: 'FailedThreshold', failureThreshold: '0'],
            [$class: 'SkippedThreshold', failureThreshold: '0']
          ],
          tools: [[$class: 'GoogleTestType', pattern: 'ut.xml']]
        ])
53
54
55
56
57
58
*/
        if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
          withSonarQubeEnv('SonarQube') {
            sh "./centreon-build/jobs/connector/${serie}/mon-connector-analysis.sh"
          }
        }
59
      }
60
   }
61
62
63
64
65
66
67
68
69
    if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
      error('Unit tests stage failure.');
    }
  }

  stage('Package') {
    parallel 'centos7': {
      node {
        sh 'setup_centreon_build.sh'
70
        sh "./centreon-build/jobs/connector/${serie}/mon-connector-package.sh centos7"
71
      }
72
73
74
75
76
77
    },
    'centos8': {
      node {
        sh 'setup_centreon_build.sh'
        sh "./centreon-build/jobs/connector/${serie}/mon-connector-package.sh centos8"
      }
78
79
80
81
82
    }
    if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
      error('Package stage failure.');
    }
  }
83
84
85
86
87
88
89
90
91
92
93
94

  if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
    stage('Delivery') {
      node {
        sh 'setup_centreon_build.sh'
        sh "./centreon-build/jobs/connector/${serie}/mon-connector-delivery.sh"
      }
      if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
        error('Delivery stage failure.');
      }
    }
  }
95
96
97
}
finally {
  buildStatus = currentBuild.result ?: 'SUCCESS';
98
  if ((buildStatus != 'SUCCESS') && ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE'))) {
99
100
101
    slackSend channel: '#monitoring-metrology', message: "@channel Centreon Connector build ${env.BUILD_NUMBER} of branch ${env.BRANCH_NAME} was broken by ${source.COMMITTER}. Please fix it ASAP."
  }
}