Compare commits

...

12 Commits

Author SHA1 Message Date
9e6815aa31 Merge pull request 'Add jenkins build' (#1) from jenkins into main
Reviewed-on: #1
2023-11-30 17:33:11 +00:00
47e47236ab
Add GUID to items 2023-11-30 18:29:10 +01:00
fbeb1b31d9
Fix sonar analysis block 2023-11-10 19:27:55 +01:00
84d9b15628
Formatting 2023-11-10 19:23:45 +01:00
9b0c592e1d
comment in analysis, skip clean 2023-11-10 19:11:06 +01:00
51267903be
quote other env vars 2023-11-10 19:01:50 +01:00
1ef4131953
quote env var 2023-11-10 19:00:50 +01:00
27b005b4ea
configure sonarqube scanner 2023-11-10 18:58:06 +01:00
4ccaf9976a
Add env block for build stagw 2023-11-10 18:41:23 +01:00
f2c2d2a18b
Add environment for cargo 2023-11-10 18:32:32 +01:00
3b72d5a4d7
Comment our environment 2023-11-10 18:21:13 +01:00
3c6785df76
Add jenkinsfile 2023-11-10 18:19:44 +01:00
3 changed files with 61 additions and 1 deletions

54
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,54 @@
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: "100"))
skipDefaultCheckout(true)
}
triggers {
pollSCM("*/10 * * * *")
}
environment {
SONAR_SCANNER_VERSION="4.7.0.2747"
SONAR_SCANNER_HOME="$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux"
PATH="$SONAR_SCANNER_HOME/bin:$PATH"
SONAR_SCANNER_OPTS="-server"
}
stages {
stage('Checkout') {
steps{
//cleanWs()
checkout scm
}
}
/*stage('Clean') {
steps {
withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { // Cargo needs to be installed for the jenkins user
sh 'cargo clean'
}
}
}*/
stage('Build') {
steps {
withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) {
withEnv(["PATH+RUST=$HOME/.cargo/bin"]) {
sh 'cargo build --release'
}
}
}
}
// For this to work, edit sonar-scanner script to set use_embedded_jre=false
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) {
withEnv(["PATH+RUST=$HOME/.cargo/bin"]) {
sh """
SONAR_TOKEN="$SONAR_AUTH_TOKEN"
cargo clippy --message-format=json &> clippy-output.json
sonar-scanner -Dsonar.projectKey=bib-watcher -Dsonar.sources=. -Dsonar.host.url=http://grover.local:9000
"""
}
}
}
}
}
}

1
sonar-project.properties Normal file
View File

@ -0,0 +1 @@
community.rust.clippy.reportPaths=clippy-output.json

View File

@ -1,6 +1,6 @@
use config::Config;
use reqwest::header;
use rss::{Channel, ChannelBuilder, ItemBuilder};
use rss::{Channel, ChannelBuilder, GuidBuilder, ItemBuilder};
use scraper::{Html, Selector};
use std::collections::HashMap;
use std::{error::Error, fs::File, io::BufReader};
@ -84,12 +84,17 @@ fn search(url: &str, title: &str) -> Result<(), Box<dyn Error>> {
.build()),
}?;
let mut items = channel.clone().into_items();
let guid = GuidBuilder::default()
.value(title.to_string() + &Utc::now().to_rfc2822())
.permalink(false)
.build();
items.push(
ItemBuilder::default()
.title(Some(title.to_string()))
.pub_date(Some(Utc::now().to_rfc2822()))
.link(Some(url.to_string()))
.description(Some(status))
.guid(Some(guid))
.build(),
);
channel.set_items(items);