Last active
May 24, 2022 15:38
-
-
Save nadvolod/e0e53cd19206a20d2fe437fa585144cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://sealights.atlassian.net/wiki/spaces/SUP/pages/752648435/Using+Sealights+from+a+Jenkins+Pipeline+job | |
// working version | |
pipeline { | |
// agent instructs Jenkins to allocate an executor | |
agent any | |
tools { | |
// Install maven | |
maven "maven3.6" | |
} | |
// bulk of work is located here like Build, Test, and Deploy | |
stages { | |
stage('Pre-Build') { | |
// The steps section defines a series of one or more steps to be executed in a given stage directive | |
steps { | |
// cleaned up the echo command | |
echo 'Starting the script' | |
// Wipe out workspace | |
cleanWs() | |
git 'https://github.com/deepak2717/HelloWorldMaven.git' | |
// sh 'param1 = "clean compile"' | |
script{ | |
env.PARAM1 = '"clean compile"' | |
echo "${env.PARAM1}" | |
} | |
sh ''' | |
echo '{ | |
"token": "MyToken", | |
"createBuildSessionId": true, | |
"appName": "${env.JOB_NAME}", | |
"branchName": "feature/sealight", | |
"buildName": "${env.BUILD_NUMBER}", | |
"packagesIncluded": "*com.kuhniverse.*", | |
"packagesExcluded": "", | |
"filesIncluded": "*.class", | |
"filesExcluded": "*test-classes*", | |
"recursive": true, | |
"includeResources": true, | |
"testStage": "${SUREFIRE_TEST_STAGE}", | |
"failsafeArgLine": "deploy", | |
"labId": "clean compile", | |
"executionType": "full", | |
"logEnabled": false, | |
"logDestination": "console", | |
"logLevel": "off", | |
"logFolder": "/tmp", | |
"sealightsJvmParams": { | |
"slScmProvider": "test", | |
"sl.scm.baseUrl": "https://{dns}/projects/{project}/repos/{repo}/browse", | |
"sl.scm.version": "4.9.0"}, | |
"enabled": true | |
}' > slmaven.json | |
''' | |
} | |
} | |
stage('Build') { | |
// mvn ${labId} | |
steps { | |
sh''' | |
echo "$env.PARAM1" | |
labId=$(cat slmaven.json | /usr/local/bin/jq -r '.labId') | |
echo "$labId" | |
''' | |
} | |
} | |
stage('Test'){ | |
// mvn ${provider} | |
// this step wanted to run mvn test | |
steps { | |
sh ''' | |
provider=$(cat slmaven.json | /usr/local/bin/jq -r '.sealightsJvmParams.slScmProvider') | |
echo "$provider" | |
echo "can deploy using command: mvn ${provider}" | |
''' | |
} | |
} | |
stage('Deploy') { | |
steps { | |
sh''' | |
arg=$(cat slmaven.json | /usr/local/bin/jq -r '.failsafeArgLine') | |
echo "can deploy using command: mvn ${arg}" | |
''' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment