Versions Compared

Key

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

...

Code Block
languagegroovy
pipeline {
    agent any

    environment {
    

  SAMPLE_SL_TOKEN = "eyJhbGci...IgETt24"
    }
    
    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 {
            
   script {            withCredentials([string(credentialsId: 'sl.token.dev.cs',        sh '''
variable: 'SL_TOKEN')]) {
                  sh set'''
+x                  echo -n "$SL_TOKEN" > sltoken.txt
                  '''
                   }
 echo "Downloading Sealights Latest Agent..."           
         wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip     script {
              unzip -o sealights-java-latest.zip    sh '''
               echo "Local agent version is now:" `cat sealights-java-version.txt`

                    echo  '{
                    "tokentokenFile": "${env.SAMPLE_SL_TOKEN}sltoken.txt",
                    "createBuildSessionId": true,
                    "appName": "${env.JOB_NAME}",  
                    "branchName": "master",
                    "buildName": "${env.BUILD_NUMBER}", 
                    "packagesIncluded": "*info.puzz.*",  
                    "packagesExcluded": "",
                    "filesIncluded": "*.class",
                    "filesExcluded": "*test-classes*",
                    "recursive": true,
                    "includeResources": true,
                    "testStage": "Unit Tests",
                    "labId": null,
                    "executionType": "full",
                    "logEnabled": true,
                    "logDestination": "console",
                    "logLevel": "error",
                    "logFolder": "/tmp",
                    "sealightsJvmParams": {},
                    "enabled": true
                     }' > slmaven.json

                    set +x
                    echo "Downloading Sealights Latest Agent..."
                    wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip
                    unzip -o sealights-java-latest.zip
                    echo "Local agent version is now:" `cat sealights-java-version.txt`
                    echo
                    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"
  
         }
 
      }
   }
}