Commit e883a322 authored by Zakaria Guennoune's avatar Zakaria Guennoune
Browse files

init centreon

parent bb9cd56c
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at []( All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [][version]
\ No newline at end of file
# Contributing to Centreon project
:clap: First thing first... Thank you for taking the time to contribute to Centreon project ! :clap: Much appreciated ! :metal:
This article contains guidelines for contributing to [Centreon]( project.
### Table of contents
[I have a question](#i-have-a-question-)
[How can I contribute?](#-how-can-i-contribute-)
- [Where should I report ?](#-where-shoud-i-report-)
- [I have an issue to report](#-i-have-an-issue-to-report-)
- [I have a suggestion of enhancement](#-i-have-a-suggestion-of-enhancement-)
- [I have a pull request to submit](#-i-have-a-pull-request-to-submit-)
[Centreon style guides](#-centreon-style-guides-)
- [Formating commit messages](#-formating-commit-messages-)
- [Coding style](#-coding-style-)
## Code of Conduct
Any people that wants to contribute and participate in developping the project must respect [Centreon Code of Conduct]( Please report any unacceptable behavior to [](
## I have a question
> **Advise**: Centreon GitHub is meant for opening issues (code related), feature requests and so on. It is not **meant** for **support**. Please refer to the following available ressources, you'll get an answer from a Centreon team or community member.
- [Official Centreon Slack](
## How can I contribute
Centreon community can contribute in **many ways** to the project.
### Where shoud I report ?
Issues and feature requests should be done on the **appropriate repositories**. Here are the repositories maintened by Centreon:
| Modules
| -------
| [centreon-broker](
| [centreon-engine](
| [centreon-clib](
| [centreon-connectors](
| [centreon-plugins](
| [centreon-dsm](
| [centreon-vmware](
| Widgets
| -------------
| [centreon-widget-host-monitoring](
| [centreon-widget-service-monitoring](
| [centreon-widget-hostgroup-monitoring](
| [centreon-widget-servicegroup-monitoring](
| [centreon-widget-graph-monitoring](
| [centreon-widget-httploader](
| [centreon-widget-global-health](
| [centreon-widget-broker-status](
| [centreon-widget-engine-status](
### I have an issue to report
Before reporting an issue please make sure that it has not been already reported by checking [Centreon Bug Tracker](
If your issue has **not** been reported yet, then the issue should be opened using the following template [](.github/
### I have a suggestion of enhancement
Any ideas, enhancements, feature requests are more than welcome. Feature requests should be opened by using the following template [](.github/
### I have a pull request to submit
You have been working on Centreon base code and want to submit it to us. Well... Again you are more than welcome and thank you in advance ! :clap:
The pull request must comply with certain requirements which are set out in the following template
> **Notice**: A pull request which contains more than the described modifications or contains more than one issue will
be rejected. Kindly write a detailed description and open one pull request per issue.
If the pull request matches the expected requirements, it will be added to a refinement session with the development team and the product owner.
If everything is clear, the pull request will be integrated to the development workflow and will be merged if it successfully passes our Continuous Integration's acceptance tests.
Afterwards, our Quality Assurance team will test it again to avoid any regressions before the pull request is released.
If the development team needs more details, they will contact you about the pull request. Please stay tuned.
> **Warning**: Any pull request that does not respect the requirements will ultimately be rejected ! In addition,
if you are asked to do so, you must help us understand your changes or behavior, and respond to us within 8 days.
> **Notice**: We used another open source project's contribution model as inspiration to provide better communication on your pull request's status :
Visual Studio Code.
Here are the labels and descriptions we may add to your work.
| Label | Reason |
| :----- | :------ |
| ```pr/external``` | The first badge |
| ```status/accepted``` | The development team has approved your modifications |
| ```status/implemented``` | The PR has been added or may have already been released in next version |
| ```status/duplicate``` | Another PR is already open |
| ```status/invalid``` | The requirements are not met |
| ```status/in-backlog``` | The development team has groomed your proposition and will work on it soon |
| ```status/could-not-reproduce``` | The dev was unable to reproduce the use-case and may need more information |
| ```status/needs-attention``` | This PR is on hold. The reason is specified in the issue |
| ```status/needs-merge``` | A dev needs to merge your work |
| ```status/too-dangerous``` | The modification seems to impact too much features or may introduce side effects |
| ```status/multiple-issues``` | The modifications contain more than one issue in a single PR |
| ```status/out-of-scope``` | The modifications are out of the described scope |
| ```status/more-info-needed``` | A dev asked you for more details and is waiting for your reply |
| ```status/wont-fix``` | The modifications do not fix the described behavior |
### Centreon style guides
#### Formating commit messages
The commit format should follow this commit template message
<type>(<scope>): <subject>
The format explanation can be found [here](
The ***body*** section needs to be clear, made of complete sentences introducing the purpose of the commit and the context, making code reviews much easier.
The ***footer*** should contain reference(s) to the ticket(s) related to the commit.
Applied to the sample ticket
Refs: #5567 (GitHub) or MON-2234 (Jira)
The ***type*** can refer to
- **feat**: adding a feature
- **fix**: adding a patch
- **enh**: adding an enhancement
- **docs**: adding documentation changes
- **style**: fixing coding style issues
- **refactor**: code refactoring
- **test**: adding new tests or fixing old ones
- **chore** : updating project construction files (Jenkins files, CMakefile, gulp, webpack ...)
The ***scope*** is defined by project. Scopes for Centreon Open Source project are related to the modifications.
For example: fix(***security***) or feat(***hostgroup***)
#### Coding style
Centreon software is made of several languages. For each language a specific coding style **must be respected**.
> **Notice**: For some languages, a bot may ask you to rework the formatting of your code. Until you make the
modifications, we won't be able to add your work to the refinement loop.
Since the 18.10 version of Centreon REACT has been introduced and Centreon follows the [airbnb]( react coding style.
For other languages, coding style rules are defined in Centreon GitHub repository
* [PHP](
* [CSS](
* [HTML](
* [JavaScript](
#### Documentation
If you want to visualize and suggest modification to the documentation through a pull request
you can check the **HOW TO** build the documentation section [here](doc/
* Copyright 2005-2021 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation ; either version 2 of the License.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <>.
* Linking this program statically or dynamically with other modules is making a
* combined work based on this program. Thus, the terms and conditions of the GNU
* General Public License cover the whole combination.
* As a special exception, the copyright holders of this program give Centreon
* permission to link this program with independent modules to produce an executable,
* regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of Centreon choice, provided that
* Centreon also meet, for each linked independent module, the terms and conditions
* of the license of that module. An independent module is a module which is not
* derived from this program. If you modify this program, you may extend this
* exception to your version of the program, but you are not obliged to do so. If you
* do not wish to do so, delete this exception statement from your version.
* For more information :
* Smarty eval function
* @param array $params
* @param \Smarty $smarty
function smarty_function_eval($params, &$smarty)
if (!isset($params['var'])) {
$smarty->trigger_error("eval: missing 'var' parameter");
if ($params['var'] == '') {
return $smarty->fetch("eval:" . $params['var']);
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
** Variables.
def serie = '22.04'
def stableBranch = "master"
def devBranch = "develop"
env.REF_BRANCH = stableBranch
if (env.BRANCH_NAME.startsWith('release-')) {
env.DELIVERY_STAGE = 'Delivery to testing'
} else if (env.BRANCH_NAME == stableBranch) {
env.DELIVERY_STAGE = 'Delivery to canary'
} else if (env.BRANCH_NAME == devBranch) {
env.BUILD = 'QA'
env.DELIVERY_STAGE = 'Delivery to unstable'
} else {
env.BUILD = 'CI'
if (env.CHANGE_BRANCH) {
def backendFiles = [
def frontendFiles = [
def hasFrontendChanges = true
def hasBackendChanges = true
def apiFeatureFiles = []
def featureFiles = []
def acceptanceTag = ""
// Skip sonarQ analysis on branch without PR - Unable to merge
def securityAnalysisRequired = 'yes'
if (!env.CHANGE_ID && env.BUILD == 'CI') {
securityAnalysisRequired = 'no'
** Functions
def isStableBuild() {
return ((env.BUILD == 'REFERENCE') || (env.BUILD == 'QA'))
def hasChanges(patterns) {
if (isStableBuild()) {
return true
def isMatching = false
sh "git config --add remote.origin.fetch +refs/heads/${env.REF_BRANCH}:refs/remotes/origin/${env.REF_BRANCH}"
sh "git fetch --no-tags"
sh "git config none"
sh "git config none"
sh "git pull --rebase origin ${env.REF_BRANCH} || git rebase --abort || true"
def diffFiles = sh(script: "git diff --name-only origin/${env.REF_BRANCH} --", returnStdout: true).trim().split()
for (file in diffFiles) {
for (pattern in patterns) {
if (SelectorUtils.match(pattern, file)) {
isMatching = true
return isMatching
def checkoutCentreonBuild() {
dir('centreon-build') {
retry(3) {
checkout resolveScm(
source: [
$class: 'GitSCMSource',
remote: '',
credentialsId: 'technique-ci',
traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait']]
targets: [env.BUILD_BRANCH, 'master']
** Pipeline code.
stage('Deliver sources') {
node {
dir('centreon-web') {
checkout scm
if (!isStableBuild()) {
hasFrontendChanges = hasChanges(frontendFiles)
hasBackendChanges = hasChanges(backendFiles)
// git repository is stored for the Sonar analysis below.
sh 'tar czf centreon-web-git.tar.gz centreon-web'
stash name: 'git-sources', includes: 'centreon-web-git.tar.gz'
// resuming process
sh "./centreon-build/jobs/web/${serie}/"
source = readProperties file: ''
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
stash name: 'tar-sources', includes: "centreon-web-${env.VERSION}.tar.gz"
stash name: 'cypress-node-modules', includes: "cypress-node-modules.tar.gz"
stash name: 'vendor', includes: 'vendor.tar.gz'
stash name: 'node_modules', includes: 'node_modules.tar.gz'
stash name: 'api-doc', includes: 'centreon-api-v22.04.html'
stash name: 'centreon-injector', includes: 'centreon-injector.tar.gz'
allowMissing: false,
keepAll: true,
reportDir: 'summary',
reportFiles: 'index.html',
reportName: 'Centreon Build Artifacts',
reportTitles: ''
// get api feature files
apiFeatureFiles = sh(
script: 'find centreon-web/tests/api/features -type f -name "*.feature" -printf "%P\n" | sort',
returnStdout: true
// get tests E2E feature files
e2eFeatureFiles = sh(
script: 'find centreon-web/tests/e2e/cypress/integration -type f -name "*.feature" -printf "%P\n" | sort',
returnStdout: true
//FIXME : reintegrate ldap features after fixing them
featureFiles = sh(
script: "rm centreon-web/features/Ldap*.feature && find centreon-web/features -type f -name '*.feature' | sed -e 's#centreon-web/features/##g' | sort",
returnStdout: true
try {
stage('Unit tests // Sonar analysis // RPMs Packaging') {
parallel 'frontend': {
if (!hasFrontendChanges) {
} else {
node {
unstash 'tar-sources'
unstash 'node_modules'
sh "./centreon-build/jobs/web/${serie}/ frontend"
referenceJobName: "centreon-web/${env.REF_BRANCH}",
enabledForFailure: true,
qualityGates: [[threshold: 1, type: 'NEW', unstable: false]],
tool: esLint(id: 'eslint', name: 'eslint', pattern: 'codestyle-fe.xml'),
trendChartType: 'NONE'
junit 'ut-fe.xml'
stash name: 'ut-fe.xml', includes: 'ut-fe.xml'
stash name: 'codestyle-fe.xml', includes: 'codestyle-fe.xml'
allowMissing: false,
keepAll: true,
reportDir: "coverage/lcov-report",
reportFiles: 'index.html',
reportName: 'Centreon Frontend Code Coverage',
reportTitles: ''
'backend': {
if (!hasBackendChanges) {
} else {
node {
unstash 'tar-sources'
unstash 'vendor'
sh "./centreon-build/jobs/web/${serie}/ backend"
//Recording issues in Jenkins job
referenceJobName: "centreon-web/${env.REF_BRANCH}",
enabledForFailure: true,
qualityGates: [[threshold: 1, type: 'DELTA', unstable: false]],
tool: phpCodeSniffer(id: 'phpcs', name: 'phpcs', pattern: 'codestyle-be.xml'),
trendChartType: 'NONE'
referenceJobName: "centreon-web/${env.REF_BRANCH}",
enabledForFailure: true,
qualityGates: [[threshold: 1, type: 'DELTA', unstable: false]],
tool: phpStan(id: 'phpstan', name: 'phpstan', pattern: 'phpstan.xml'),
trendChartType: 'NONE'
junit 'ut-be.xml'
stash name: 'ut-be.xml', includes: 'ut-be.xml'
stash name: 'coverage-be.xml', includes: 'coverage-be.xml'
stash name: 'codestyle-be.xml', includes: 'codestyle-be.xml'
stash name: 'phpstan.xml', includes: 'phpstan.xml'
'sonar': {
node {
if (securityAnalysisRequired == 'no') {
} else {
// Run sonarQube analysis
unstash 'git-sources'
unstash 'vendor'
unstash 'node_modules'
sh 'rm -rf centreon-web && tar xzf centreon-web-git.tar.gz'
sh 'rm -rf centreon-web/vendor && tar xzf vendor.tar.gz -C centreon-web'
sh 'rm -rf centreon-web/node_modules && tar xzf node_modules.tar.gz -C centreon-web'
withSonarQubeEnv('SonarQubeDev') {
sh "./centreon-build/jobs/web/${serie}/"
// sonarQube step to get qualityGate result
timeout(time: 10, unit: 'MINUTES') {
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qualityGate.status}"
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error("Quality gate failure: ${qualityGate.status}.");
'rpm packaging centos7': {
node {
unstash 'tar-sources'
sh "./centreon-build/jobs/web/${serie}/ centos7"
archiveArtifacts artifacts: "rpms-centos7.tar.gz"
stash name: "rpms-centos7", includes: 'output/noarch/*.rpm'
sh 'rm -rf output'
'rpm packaging alma8': {
node {
unstash 'tar-sources'
sh "./centreon-build/jobs/web/${serie}/ alma8"
archiveArtifacts artifacts: "rpms-alma8.tar.gz"
stash name: "rpms-alma8", includes: 'output/noarch/*.rpm'
sh 'rm -rf output'
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Unit tests // RPM Packaging Failure');
if (env.CHANGE_ID) { // pull request to comment with coding style issues
stage('Violations to Github') {
node {
if (hasBackendChanges) {
unstash 'codestyle-be.xml'
unstash 'phpstan.xml'
if (hasFrontendChanges) {
unstash 'codestyle-fe.xml'
repositoryName: 'centreon',
pullRequestId: env.CHANGE_ID,
createSingleFileComments: true,
commentOnlyChangedContent: true,
commentOnlyChangedFiles: true,
keepOldComments: false,
commentTemplate: "**{{violation.severity}}**: {{violation.message}}",
violationConfigs: [
[parser: 'CHECKSTYLE', pattern: '.*/codestyle-be.xml$', reporter: 'Checkstyle'],
[parser: 'CHECKSTYLE', pattern: '.*/phpstan.xml$', reporter: 'Checkstyle'],
[parser: 'CHECKSTYLE', pattern: '.*/codestyle-fe.xml$', reporter: 'Checkstyle']
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error("Reports stage failure");
stage('Docker packaging') {
def parallelSteps = [:]
def osBuilds = isStableBuild() ? ['centos7', 'alma8'] : ['centos7']
for (x in osBuilds) {
def osBuild = x
parallelSteps[osBuild] = {
node {
sh 'rm -rf output'