bib-watcher/Jenkinsfile

54 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-11-10 17:19:44 +00:00
pipeline {
2023-11-10 17:41:23 +00:00
agent any
options {
buildDiscarder(logRotator(numToKeepStr: "100"))
skipDefaultCheckout(true)
}
triggers {
pollSCM("*/10 * * * *")
}
environment {
2023-11-10 18:00:50 +00:00
SONAR_SCANNER_VERSION="4.7.0.2747"
2023-11-10 18:01:50 +00:00
SONAR_SCANNER_HOME="$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux"
PATH="$SONAR_SCANNER_HOME/bin:$PATH"
2023-11-10 17:58:06 +00:00
SONAR_SCANNER_OPTS="-server"
2023-11-10 17:41:23 +00:00
}
stages {
2023-11-10 18:23:45 +00:00
stage('Checkout') {
2023-11-10 17:41:23 +00:00
steps{
2023-11-10 18:23:45 +00:00
//cleanWs()
2023-11-10 17:41:23 +00:00
checkout scm
2023-11-10 18:23:45 +00:00
}
}
/*stage('Clean') {
2023-11-10 17:41:23 +00:00
steps {
2023-11-10 17:58:06 +00:00
withEnv(["PATH+RUST=$HOME/.cargo/bin"]) { // Cargo needs to be installed for the jenkins user
2023-11-10 17:41:23 +00:00
sh 'cargo clean'
2023-11-10 17:19:44 +00:00
}
2023-11-10 17:41:23 +00:00
}
2023-11-10 18:11:06 +00:00
}*/
2023-11-10 18:23:45 +00:00
stage('Build') {
2023-11-10 17:41:23 +00:00
steps {
2023-11-10 17:58:06 +00:00
withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) {
2023-11-10 17:41:23 +00:00
withEnv(["PATH+RUST=$HOME/.cargo/bin"]) {
sh 'cargo build --release'
}
2023-11-10 17:19:44 +00:00
}
2023-11-10 17:41:23 +00:00
}
}
2023-11-30 17:29:10 +00:00
// For this to work, edit sonar-scanner script to set use_embedded_jre=false
2023-11-10 17:41:23 +00:00
stage('SonarQube Analysis') {
steps {
2023-11-10 18:23:45 +00:00
withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) {
2023-11-10 18:27:55 +00:00
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
"""
}
2023-11-10 17:19:44 +00:00
}
2023-11-10 17:41:23 +00:00
}
2023-11-10 17:19:44 +00:00
}
2023-11-10 17:41:23 +00:00
}
2023-11-10 17:19:44 +00:00
}