Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
pipeline {
    agent any

    tools {
      jdk '1.8'
    }
    
   stages {
       
        stage('Git') {
            steps {
                // Wipe out workspace
                cleanWs()

                // Get some code from a GitHub repository
                git 'https://github.com/marcsealights/java-gps-calorie-calculator.git'
            }
        }       
       
       stage ("Adding Sealights") {
            steps {
                             withCredentials([string(credentialsId: 'sl.agenttoken.dev.tokencs', variable: 'SL_TOKEN')]) {
                  sh '''
                  echo -n "$SL_TOKEN" > sltoken.txt

                  echo "Downloading Sealights Latest Agent..."
                  wget -nv  https://agents.sealights.co/sealights-java/sealights-java-latest.zip
                  unzip -oq sealights-java-latest.zip
                  echo "Local agent version is now:" `cat sealights-java-version.txt` "\n"
                  '''
                }
                
				writeFile file:               script {
                    sh '''
                    echo  '{
                        'slmaven.json', text: '''\
				|{
				|  "executionType": "full",
                        "tokenFile				|  "tokenFile": "sltoken.txt",
                        				|  "createBuildSessionId": true,
                        				|  "appName": "${env.JOB_NAME}",  
                        				|  "branchName": "${env.BRANCH_NAME}",
                     |   "buildName": "${env.BUILD_NUMBER}", 
                |        "packagesIncluded": "*info.puzz.*",  //Specific to your app
                    |    "packagesExcluded": "",
				|  "includeResources":                    true,
				|  "filesIncludedtestStage": "*.classUnit Tests",
				|  "sealightsJvmParams":                  {
				|    "filesExcludedsl.scm.provider": "*test-classes*github", 
            				|           "recursive": true,
                        "includeResources": true,
                        "testStage": "Unit Tests",
                        "labId": null,
                        "sl.scm.baseUrl": "https://github.com/marcsealights/java-gps-calorie-calculator/blob/",
				|    "sl.scm.version": "GITHUBVERSION_VAR"
				|  },
				|  "proxy": null,
				|  "logEnabled": false,
                        				|  "logDestination": "console",
                        				|  "logLevel": "off",
				|}
				'''.stripMargin().stripIndent()

				script{
					sh'''
						#export                   "logFolder": "/tmp",
                        "sealightsJvmParams": {},
                        "enabled": true
                     }' > slmaven.json

                    gitlabVersion=`curl https://mygitlab.mycompany.com/api/v4/version | jq -r .version`
						export githubVersion='2.19.0'
						sed -i "s~GITHUBVERSION_VAR~$githubVersion~" slmaven.json

						echo "Updating POM with Sealights..."
                    						java -jar sl-build-scanner.jar -pom -configfile slmaven.json -workspacepath .
                 ''' 
                }
            }
        }
       
      stage('Build') {
            steps {
                // Run Maven with regular command
                sh "mvn clean package"
         }
      }
   }
}

...