From b66ccf52021a2dbd50dd909df37478b2138c4949 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 1 Feb 2023 23:47:29 +0000 Subject: [PATCH] environment test --- Jenkinsfile | 7 +++++-- build.gradle | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3ac5854..56dc00d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,12 +46,15 @@ podTemplate( stage('Test') { try { container('gradle') { - def projectDetails = sh(returnStdout: true, script: "gradle -q projectDetails").trim() + def projectName = sh(returnStdout: true, script: "gradle -q projectName").trim() + def projectVersion = sh(returnStdout: true, script: "gradle -q projectVersion").trim() + env.PROJECT_NAME = projectName + env.PROJECT_VERSION = projectVersion + sh """ pwd echo "GIT_BRANCH=${gitBranch}" >> /etc/environment echo "GIT_COMMIT=${gitCommit}" >> /etc/environment - echo "${projectDetails}" >> /etc/environment gradle test """ } diff --git a/build.gradle b/build.gradle index 5ce7e56..6a908e7 100644 --- a/build.gradle +++ b/build.gradle @@ -21,9 +21,13 @@ tasks.named('test') { useJUnitPlatform() } -task projectDetails { +task projectName { doLast { - println "PROJECT_NAME=${project.name}" - println "PROJECT_VERSION=${project.version}" + println "${project.name}" + } +} +task projectVersion { + doLast { + println "${project.version}" } }