From 3c6785df76d0a5aa63643e92d331f05c288d8e7e Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 18:19:44 +0100 Subject: [PATCH 01/11] Add jenkinsfile --- Jenkinsfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..d346c08 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,46 @@ +pipeline { + agent any + options { + buildDiscarder(logRotator(numToKeepStr: "100")) + skipDefaultCheckout(true) + } + triggers { + pollSCM("*/10 * * * *") + } + environment { + /* + MSBUILD_SQ_SCANNER_HOME = tool name: 'sonarscanner', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation' + DOTNET_USE_POLLING_FILE_WATCHER = true + DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE = false + */ + } + stages { + stage('Checkout'){ + steps{ + cleanWs() + checkout scm + } + } + stage('Clean'){ + steps{ + sh 'cargo clean' + } + } + stage('Build'){ + steps { + withSonarQubeEnv(installationName: 'grover.local:9000', envOnly: true) { + sh 'cargo build --release' + } + } + } + /* + stage('SonarQube Analysis'){ + steps { + withSonarQubeEnv('grover.local:9000') { + sh "dotnet ${MSBUILD_SQ_SCANNER_HOME}/SonarScanner.MSBuild.dll end" + } + } + } + */ + } +} \ No newline at end of file -- 2.39.5 From 3b72d5a4d75f3311cce37e1c783918e9f185abfa Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 18:21:13 +0100 Subject: [PATCH 02/11] Comment our environment --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d346c08..5804b8c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,13 +7,13 @@ pipeline { triggers { pollSCM("*/10 * * * *") } + /* environment { - /* MSBUILD_SQ_SCANNER_HOME = tool name: 'sonarscanner', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation' DOTNET_USE_POLLING_FILE_WATCHER = true DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE = false - */ } + */ stages { stage('Checkout'){ steps{ -- 2.39.5 From f2c2d2a18b0cddcac5ac756be117ef2787b085da Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 18:32:32 +0100 Subject: [PATCH 03/11] Add environment for cargo --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5804b8c..4cd07b7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,10 @@ pipeline { } } stage('Clean'){ - steps{ - sh 'cargo clean' + steps { + withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { + sh 'cargo clean' + } } } stage('Build'){ -- 2.39.5 From 4ccaf9976a26382ccf04d651726aaeda502c0a61 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 18:41:23 +0100 Subject: [PATCH 04/11] Add env block for build stagw --- Jenkinsfile | 84 +++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4cd07b7..5b4bcc7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,48 +1,50 @@ pipeline { - agent any - options { - buildDiscarder(logRotator(numToKeepStr: "100")) - skipDefaultCheckout(true) + agent any + options { + buildDiscarder(logRotator(numToKeepStr: "100")) + skipDefaultCheckout(true) + } + triggers { + pollSCM("*/10 * * * *") + } + /* + environment { + MSBUILD_SQ_SCANNER_HOME = tool name: 'sonarscanner', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation' + DOTNET_USE_POLLING_FILE_WATCHER = true + DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE = false + } + */ + stages { + stage('Checkout'){ + steps{ + cleanWs() + checkout scm + } } - triggers { - pollSCM("*/10 * * * *") + stage('Clean'){ + steps { + withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { + sh 'cargo clean' + } + } + } + stage('Build'){ + steps { + withSonarQubeEnv(installationName: 'grover.local:9000', envOnly: true) { + withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { + sh 'cargo build --release' + } + } + } } /* - environment { - MSBUILD_SQ_SCANNER_HOME = tool name: 'sonarscanner', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation' - DOTNET_USE_POLLING_FILE_WATCHER = true - DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE = false + stage('SonarQube Analysis') { + steps { + withSonarQubeEnv('grover.local:9000') { + sh "dotnet ${MSBUILD_SQ_SCANNER_HOME}/SonarScanner.MSBuild.dll end" + } + } } */ - stages { - stage('Checkout'){ - steps{ - cleanWs() - checkout scm - } - } - stage('Clean'){ - steps { - withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { - sh 'cargo clean' - } - } - } - stage('Build'){ - steps { - withSonarQubeEnv(installationName: 'grover.local:9000', envOnly: true) { - sh 'cargo build --release' - } - } - } - /* - stage('SonarQube Analysis'){ - steps { - withSonarQubeEnv('grover.local:9000') { - sh "dotnet ${MSBUILD_SQ_SCANNER_HOME}/SonarScanner.MSBuild.dll end" - } - } - } - */ - } + } } \ No newline at end of file -- 2.39.5 From 27b005b4ea431ab09900843996b179ec3cd66eda Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 18:58:06 +0100 Subject: [PATCH 05/11] configure sonarqube scanner --- Jenkinsfile | 19 +++++++++++-------- sonar-project.properties | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 sonar-project.properties diff --git a/Jenkinsfile b/Jenkinsfile index 5b4bcc7..575a225 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,13 +7,12 @@ pipeline { triggers { pollSCM("*/10 * * * *") } - /* environment { - MSBUILD_SQ_SCANNER_HOME = tool name: 'sonarscanner', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation' - DOTNET_USE_POLLING_FILE_WATCHER = true - DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE = false + 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{ @@ -23,14 +22,14 @@ pipeline { } stage('Clean'){ steps { - withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { + withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { // Cargo needs to be installed for the jenkins user sh 'cargo clean' } } } stage('Build'){ steps { - withSonarQubeEnv(installationName: 'grover.local:9000', envOnly: true) { + withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) { withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { sh 'cargo build --release' } @@ -41,7 +40,11 @@ pipeline { stage('SonarQube Analysis') { steps { withSonarQubeEnv('grover.local:9000') { - sh "dotnet ${MSBUILD_SQ_SCANNER_HOME}/SonarScanner.MSBuild.dll end" + sh """ + printenv + cargo clippy --message-format=json &> clippy-output.json + sonar-scanner -Dsonar.projectKey=bib-watcher -Dsonar.sources=. -Dsonar.host.url=http://grover.local:9000 + """ } } } diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..b3b5ea8 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1 @@ +community.rust.clippy.reportPaths=clippy-output.json \ No newline at end of file -- 2.39.5 From 1ef4131953c05f980b9224b064dbf57bd990b688 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 19:00:50 +0100 Subject: [PATCH 06/11] quote env var --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 575a225..69f94df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { pollSCM("*/10 * * * *") } environment { - SONAR_SCANNER_VERSION=4.7.0.2747 + 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" -- 2.39.5 From 51267903be62be7d8d9b18757b954f77c8d992d8 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 19:01:50 +0100 Subject: [PATCH 07/11] quote other env vars --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 69f94df..2a2987c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,8 @@ pipeline { } 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_HOME="$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux" + PATH="$SONAR_SCANNER_HOME/bin:$PATH" SONAR_SCANNER_OPTS="-server" } stages { -- 2.39.5 From 9b0c592e1d8496cc2309d9932489c94468609d8d Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 19:11:06 +0100 Subject: [PATCH 08/11] comment in analysis, skip clean --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2a2987c..0da2395 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,14 +19,14 @@ pipeline { 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) { -- 2.39.5 From 84d9b15628219674a682bb84d21f680fbdc377b2 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 19:23:45 +0100 Subject: [PATCH 09/11] Formatting --- Jenkinsfile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0da2395..95dba03 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,20 +14,20 @@ pipeline { SONAR_SCANNER_OPTS="-server" } stages { - stage('Checkout'){ + stage('Checkout') { steps{ - cleanWs() + //cleanWs() checkout scm - } - }/* - stage('Clean'){ + } + } + /*stage('Clean') { steps { withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { // Cargo needs to be installed for the jenkins user sh 'cargo clean' } } }*/ - stage('Build'){ + stage('Build') { steps { withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) { withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { @@ -36,10 +36,9 @@ pipeline { } } } - /* stage('SonarQube Analysis') { steps { - withSonarQubeEnv('grover.local:9000') { + withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) { sh """ printenv cargo clippy --message-format=json &> clippy-output.json @@ -48,6 +47,5 @@ pipeline { } } } - */ } } \ No newline at end of file -- 2.39.5 From fbeb1b31d92d123077529c7d5deb99f1a03efc87 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Fri, 10 Nov 2023 19:27:55 +0100 Subject: [PATCH 10/11] Fix sonar analysis block --- Jenkinsfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 95dba03..22e0298 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,11 +39,13 @@ pipeline { stage('SonarQube Analysis') { steps { withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) { - sh """ - printenv - cargo clippy --message-format=json &> clippy-output.json - sonar-scanner -Dsonar.projectKey=bib-watcher -Dsonar.sources=. -Dsonar.host.url=http://grover.local:9000 - """ + 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 + """ + } } } } -- 2.39.5 From 47e47236abde15847a7fc983fae46b189dbd2176 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Thu, 30 Nov 2023 18:29:10 +0100 Subject: [PATCH 11/11] Add GUID to items --- Jenkinsfile | 1 + src/main.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22e0298..6a7295b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,6 +36,7 @@ pipeline { } } } + // 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) { diff --git a/src/main.rs b/src/main.rs index 501bf93..8a2bf61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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> { .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); -- 2.39.5