Skip to content
Open
80 changes: 33 additions & 47 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
pipeline {
agent any
stages {
stage('Lint') {
steps {
parallel(
"Lint": {
sh 'echo \'linted!\''

},
"Time": {
sh 'echo "date"'

}
)
}
}
stage('SonarQube analysis') {
steps {
// requires SonarQube Scanner 2.8+
withSonarQubeEnv('sonar') {
sh "./helloworld/sonar-scanner/bin/sonar-scanner"
}
}
}
stage('Deploy') {
steps {
sh 'echo "Deploying..."'
}
}
stage('Publish to Influxdb') {
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
}
}
steps {
echo 'Publishing to Influxdb'
step([$class: 'InfluxDbPublisher', customData: null, customDataMap: null, customPrefix: null, target: 'influxdb'])
}
}
node {
stage("Prepare") {
checkout scm
}
post {
always {
sh 'echo "Always in post"'
}
failure {
sh 'echo "The Pipeline failed :("'

stage('Print env') {
sh 'printenv'
}

stage("Sonar") {

// Adding variables to sonar.properties
sh "echo sonar.github.repository=multiservicio/devops-docker >> sonar-project.properties"
sh "echo sonar.analysis.mode=preview >> sonar-project.properties"
sh "echo sonar.github.pullRequest=${pullRequestId(env.BRANCH_NAME)}>> sonar-project.properties"
sh "echo sonar.github.oauth=xxxx >> sonar-project.properties"

withSonarQubeEnv('sonar') {
sh "./helloworld/sonar-scanner/bin/sonar-scanner"
}
}

stage('Publish to Influxdb') {
step([$class: 'InfluxDbPublisher', customData: null, customDataMap: null, customPrefix: null, target: 'influxdb'])
}

}

/**
* Get pull request id from branch string
*
* @param branch
* @return
*/
String pullRequestId(String branch) {
return (branch =~ /^PR-(\d+)$/)[0][1]
}
4 changes: 2 additions & 2 deletions config/devui/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<div class="nav-wrapper">
<a class="brand-logo left">&nbsp;&nbsp;[projectName]</a>
<ul class="right hide-on-med-and-down">
<li onclick="loadIframeByUrl('http://local.dev:8080')" class="nav-item"><a>Jenkins</a></li>
<li onclick="loadIframeByUrl('http://local.dev:8080/blue/pipelines')" class="nav-item"><a>Jenkins</a></li>
<li onclick="loadIframeByUrl('http://local.dev:3000')" class="nav-item"><a>Grafana</a></li>
<li onclick="loadIframeByUrl('http://local.dev:8083')" class="nav-item"><a>InfluxDB</a></li>
<li onclick="window.open('http://local.dev:9000')" class="nav-item"><a class="tooltipped" data-position="bottom" data-delay="50" data-tooltip="Opens in a new tab"><i class="right material-icons">launch</i>Sonar</a></li>

</ul>
</div>
</nav>
Expand Down
144 changes: 144 additions & 0 deletions config/grafana/dashboards/deployments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"annotations": {
"list": []
},
"description": "Deployment History",
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"id": 2,
"links": [],
"rows": [
{
"collapse": false,
"height": "250px",
"panels": [
{
"columns": [],
"filterNull": false,
"fontSize": "100%",
"height": "400px",
"id": 1,
"links": [],
"pageSize": null,
"scroll": true,
"showHeader": true,
"sort": {
"col": 0,
"desc": true
},
"span": 12,
"styles": [
{
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "Time",
"type": "date"
},
{
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"decimals": 2,
"pattern": "/.*/",
"thresholds": [],
"type": "number",
"unit": "short"
}
],
"targets": [
{
"alias": "",
"dsType": "influxdb",
"groupBy": [],
"measurement": "deployments",
"policy": "default",
"refId": "A",
"resultFormat": "table",
"select": [
[
{
"params": [
"description"
],
"type": "field"
}
],
[
{
"params": [
"title"
],
"type": "field"
}
],
[
{
"params": [
"tags"
],
"type": "field"
}
]
],
"tags": []
}
],
"title": "Deployments Log",
"transform": "table",
"transparent": true,
"type": "table"
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Dashboard Row",
"titleSize": "h6"
}
],
"schemaVersion": 14,
"style": "dark",
"tags": [
"deployment"
],
"templating": {
"list": []
},
"time": {
"from": "now-30d",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "Deployments",
"version": 1
}
Loading