Compare commits
5 Commits
8a80cc6844
...
2e8fd1d17d
| Author | SHA1 | Date |
|---|---|---|
|
|
2e8fd1d17d | |
|
|
76beff02ac | |
|
|
fa0895122c | |
|
|
91ead7d1ba | |
|
|
a30fb0d834 |
|
|
@ -34,7 +34,22 @@ pipeline {
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
env.IMAGE_TAG = sh(script: "git describe --tags --abbrev=0", returnStdout: true).trim()
|
def hasTags = sh(script: "git tag -l | wc -l", returnStdout: true).trim().toInteger() > 0
|
||||||
|
|
||||||
|
def lastVersion = "0.0.0"
|
||||||
|
|
||||||
|
if (hasTags) {
|
||||||
|
lastVersion = sh(script: "git describe --tags --abbrev=0", returnStdout: true).trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Last version: ${lastVersion}"
|
||||||
|
|
||||||
|
def (major, minor, patch) = lastVersion.tokenize('.')
|
||||||
|
def newVersion = "${major}.${minor}.${patch.toInteger() + 1}"
|
||||||
|
echo "New version: ${newVersion}"
|
||||||
|
|
||||||
|
env.IMAGE_TAG = newVersion
|
||||||
|
env.NEW_VERSION = newVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,18 +94,30 @@ pipeline {
|
||||||
echo "Attempting to merge PR ${env.CHANGE_ID} into master..."
|
echo "Attempting to merge PR ${env.CHANGE_ID} into master..."
|
||||||
withCredentials([usernamePassword(credentialsId: 'gitea_creds', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_PASS')]) {
|
withCredentials([usernamePassword(credentialsId: 'gitea_creds', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_PASS')]) {
|
||||||
def prId = env.CHANGE_ID
|
def prId = env.CHANGE_ID
|
||||||
|
|
||||||
sh """
|
sh """
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
-u "${GITEA_USER}:${GITEA_PASS}" \
|
-u "${GITEA_USER}:${GITEA_PASS}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"do":"merge"}' \
|
-d '{"do":"merge"}' \
|
||||||
http://git.entcor/api/v1/repos/deployer3000/integration-module/pulls/${prId}/merge
|
http://git.entcor/api/v1/repos/deployer3000/${env.IMAGE_NAME}/pulls/${prId}/merge
|
||||||
"""
|
"""
|
||||||
|
def commitHash = sh(script: "git rev-parse HEAD~1", returnStdout: true).trim() // необходим для корректного отображения статусов
|
||||||
echo "PR ${prId} merged successfully into master!"
|
echo "PR ${prId} merged successfully into master!"
|
||||||
|
sleep(time: 15, unit: 'SECONDS')
|
||||||
|
sh "git checkout master && git pull origin master"
|
||||||
|
|
||||||
|
sh """
|
||||||
|
curl -v -X POST -u "${GITEA_USER}:${GITEA_PASS}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"tag_name": "${env.NEW_VERSION}", "name": "Release ${env.NEW_VERSION}", "target_commitish": "master"}' \
|
||||||
|
"${env.GITEA_REPOSITORY_URL}deployer3000/${env.IMAGE_NAME}/releases"
|
||||||
|
"""
|
||||||
|
|
||||||
|
echo "New release succeeded!"
|
||||||
|
|
||||||
def context = "test-org/integration-module/pipeline/pr-${env.CHANGE_TARGET}"
|
def context = "test-org/${env.IMAGE_NAME}/pipeline/pr-${env.CHANGE_TARGET}"
|
||||||
def commitHash = sh(script: "git rev-parse HEAD~1", returnStdout: true).trim()
|
notify(context, GITEA_USER, GITEA_PASS, env.GITEA_REPOSITORY_URL, env.IMAGE_NAME, commitHash, "success")
|
||||||
notify(context, GITEA_USER, GITEA_PASS, env.GITEA_REPOSITORY_URL, "integration-module", commitHash, "success")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use reqwest::Client;
|
||||||
use tokio_postgres::NoTls;
|
use tokio_postgres::NoTls;
|
||||||
use std::env;
|
use std::env;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info, trace};
|
||||||
use std::ops::Drop;
|
use std::ops::Drop;
|
||||||
|
|
||||||
/// An entity which handles DB connections.
|
/// An entity which handles DB connections.
|
||||||
|
|
@ -113,9 +113,13 @@ impl Exporter {
|
||||||
}
|
}
|
||||||
/// Exports metrics in `PrometheusMetricsExtended` format to Exporter defined
|
/// Exports metrics in `PrometheusMetricsExtended` format to Exporter defined
|
||||||
/// as env var $EXORPTER_URL
|
/// as env var $EXORPTER_URL
|
||||||
|
#[tracing::instrument(name = "Prometheus/Status System export")]
|
||||||
pub async fn export_extended_metrics(metrics: PrometheusMetricsExtended) -> Result<usize> {
|
pub async fn export_extended_metrics(metrics: PrometheusMetricsExtended) -> Result<usize> {
|
||||||
// let url = env::var("EXPORTER_URL")?;
|
// let url = env::var("EXPORTER_URL")?;
|
||||||
let url = env::var("STATUS_SYSTEM_URL").unwrap_or(env::var("EXPORTER_URL")?);
|
let url = env::var("STATUS_SYSTEM_URL").or_else(|err| {
|
||||||
|
trace!("cannot fetch $STATUS_SYSTEM_URL var due to {}. working only with Prometheus exporter link", err);
|
||||||
|
env::var("EXPORTER_URL")
|
||||||
|
})?;
|
||||||
|
|
||||||
debug!("Exporting: {:?}", &metrics);
|
debug!("Exporting: {:?}", &metrics);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -277,8 +277,8 @@ impl MonitoringImporter {
|
||||||
match event.await {
|
match event.await {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
match crate::export::Exporter::export_extended_metrics(val?).await {
|
match crate::export::Exporter::export_extended_metrics(val?).await {
|
||||||
Ok(bytes) => {info!("Successfully transmitted {} bytes to the Prometehus exporter", bytes)},
|
Ok(bytes) => {info!("Successfully transmitted {} bytes", bytes)},
|
||||||
Err(er) => error!("Cannot export data to the Prometehus exporter due to : `{}`", er),
|
Err(er) => error!("Cannot export data due to : `{}`", er),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(er) => {
|
Err(er) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue