From 76ca32214dfe3486f674abd33f3da5a477b1764e Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 12 Feb 2024 10:38:04 +0000 Subject: [PATCH 1/6] check hashed building from HEAD --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 25de209..2684ff2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any parameters { booleanParam(name: "use_github", defaultValue: true, description: "use github repos") - booleanParam(name: "BUILD_SNAPSHOT", defaultValue: false, description: "build current version at HEAD") + booleanParam(name: "BUILD_SNAPSHOT", defaultValue: true, description: "build current version at HEAD") } options { timestamps() -- 2.40.1 From 43dafab7e4c8412c0816aa1cd96b8f70575d72e8 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 12 Feb 2024 10:41:38 +0000 Subject: [PATCH 2/6] comment out upload (should check branch name or something) --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2684ff2..3ac07a1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -63,9 +63,9 @@ pipeline { } success { archiveArtifacts(artifacts: "dist/*", fingerprint: true) - withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) { - sh ".pipeline/publish.sh" - } + //withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) { + // sh ".pipeline/publish.sh" + //} } cleanup { sh ".pipeline/clean.sh" -- 2.40.1 From afc4e940ea40c4518d0c2dee45a8fca9e72aff5a Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Mon, 12 Feb 2024 23:41:11 +0100 Subject: [PATCH 3/6] The Jenkins pipeline has chdir'd into the Valetudo repo when it invokes version.sh --- .pipeline/version.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.pipeline/version.sh b/.pipeline/version.sh index fd8eaa2..5777647 100755 --- a/.pipeline/version.sh +++ b/.pipeline/version.sh @@ -16,7 +16,13 @@ fi if [[ -n "${BUILD_SNAPSHOT}" && "${BUILD_SNAPSHOT}" != "false" ]]; then # Jenkins will set this to "false" since it is the name of the build parameter - VALETUDO_NPM_VERSION=$(jq -r .version ${PWD_REPO_PATH}/Valetudo/package.json) + if [[ "$(basename $(pwd))" == "Valetudo" ]]; then + PACKAGE_JSON="$(pwd)/package.json" + else + PACKAGE_JSON="${PWD_REPO_PATH}/Valetudo/package.json" + fi + + VALETUDO_NPM_VERSION=$(jq -r .version $PACKAGE_JSON) VALETUDO_VERSION="${VALETUDO_NPM_VERSION}-SNAPSHOT" elif [[ -z "${VALETUDO_VERSION}" ]]; then # latest tag (annotated or not) -- 2.40.1 From 34cecfa82f633ea717773015dc4ab6c060379905 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Mon, 12 Feb 2024 23:48:58 +0100 Subject: [PATCH 4/6] Skip git checkout for snapshots (for now we just assume the repo is on the latest commit available on the main branch) --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3ac07a1..1431c74 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,9 @@ pipeline { git(url: env.VALETUDO_GIT_URL + "/Valetudo", branch: env.VALETUDO_MAIN_BRANCH) sh("git fetch --tags") env.VALETUDO_VERSION = sh(script: "../.pipeline/version.sh", returnStdout: true).trim() - sh "git checkout ${env.VALETUDO_VERSION}" + if (env.BUILD_SNAPSHOT != "true") { + sh "git checkout ${env.VALETUDO_VERSION}" + } } currentBuild.displayName += " - v${env.VALETUDO_VERSION}" currentBuild.description = "Valetudo v${env.VALETUDO_VERSION}" -- 2.40.1 From 0ab17c39f98d60966446e1ac9e8242b30b53e6c9 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Mon, 12 Feb 2024 23:52:29 +0100 Subject: [PATCH 5/6] Move upload to a stage since im here --- Jenkinsfile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1431c74..f6d6507 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { script { // used in post success env.GITEA_USER = env.JOB_NAME.split('/')[0] + env.GITEA_SECRET_ID = "gitea-user-${env.GITEA_USER}-full-token" env.VALETUDO_GIT_URL = params.use_github ? "https://github.com/Hypfer" : "https://git.sudo.is/mirrors" sh "env" @@ -48,7 +49,7 @@ pipeline { sh ".pipeline/build.sh" } } - stage('Checksums') { + stage('checksums') { steps { sh ".pipeline/check-sha256sums.sh" } @@ -58,6 +59,16 @@ pipeline { sh ".pipeline/package.sh" } } + stage('publish') { + when { + branch "main" + } + steps { + withCredentials([string(credentialsId: env.GITEA_SECRET_ID, variable: 'GITEA_SECRET')]) { + sh ".pipeline/publish.sh" + } + } + } } post { always { @@ -65,9 +76,6 @@ pipeline { } success { archiveArtifacts(artifacts: "dist/*", fingerprint: true) - //withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) { - // sh ".pipeline/publish.sh" - //} } cleanup { sh ".pipeline/clean.sh" -- 2.40.1 From a6d7fa0cf5cbddb771cfb992e7b0fbf3fc51e94c Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Tue, 13 Feb 2024 00:05:53 +0100 Subject: [PATCH 6/6] Revert "check hashed building from HEAD" This reverts commit 76ca32214dfe3486f674abd33f3da5a477b1764e. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f6d6507..3cb5d96 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any parameters { booleanParam(name: "use_github", defaultValue: true, description: "use github repos") - booleanParam(name: "BUILD_SNAPSHOT", defaultValue: true, description: "build current version at HEAD") + booleanParam(name: "BUILD_SNAPSHOT", defaultValue: false, description: "build current version at HEAD") } options { timestamps() -- 2.40.1