Skip to content
DaGeRe edited this page Jan 28, 2022 · 2 revisions

Installing / Updating on Jenkins

If you are running a Jenkins server and want to update to the latest snapshot version, create a new pipeline with the following definition:

pipeline {
    agent any
    stages {
        stage('checkout') {
            steps{
                dir('peass') {
                    git url: 'https://github.com/DaGeRe/peass.git'
                }
                dir('peass-ci') {
                    git branch:'main', url: 'https://github.com/jenkinsci/peass-ci-plugin'
                }
            }
        }
        stage('build'){
            steps{
                dir('peass') {
                    sh 'unset MAVEN_CONFIG && ./mvnw clean install -DskipTests'
                }
                dir('peass-ci') {
                    sh 'unset MAVEN_CONFIG && ./mvnw clean package -DskipTests'
                    sh 'rm $JENKINS_HOME/plugins/peass-ci* -rf'
                    sh 'cp target/peass-ci.hpi $JENKINS_HOME/plugins/'
                }
            }
        }
    }
}

Afterwards, you need to restart your Jenkins. This can be done manually by visiting /restart on your installation. If you do this more often, you can also add the following stage to your pipeline:

        stage('restart') {
            steps{
                script {
                    jenkins.model.Jenkins.instance.safeRestart()
                }
            }
        }

This requires setting the following script approvals in Jenkins:

method jenkins.model.Jenkins safeRestart
staticMethod jenkins.model.Jenkins getInstance

In order to add them, you need to execute your job (which will fail), go to the log of your job and approve the signatures. Since you need to approve these two signatures, you need to run your job twice (and allow one new signature after each failed call).

The pipeline needs to remove the plugin before installing the new version, because Jenkins will otherwise extract the hpi file partially. Due to this fact, Peass-CI will only be usable after the restart (also the old plugin version will not work anymore). If you prefer to keep the old version, you could remove the rm and the cp step from the pipeline, download the built peass-ci.hpi and upload it via the Jenkins web interface.

Peass-CI Folders

Peass-CI saves all its data in subfolders of the jenkins-folder:

  • Persistent data (across runs): In the job folder $JOBFOLDER (default jobs/$JOBNAME, but might be different based on your folder structure), the folder peass-data contains all persistent data. If you delete this folder and measure a new version afterwards, the whole measurement needs to be repeated. The data include:
    • dependencies.json and execute.json describing which tests are selected by the regression test selection
    • views and properties - the data which are produced by code analysis
    • dependencyreading, executionreading and measurement_$VERSION1_$VERSION2.txt, which contain the logs of the regression test selection and the measurement
  • In your workspace folder (that might be in jobs/$JOBNAME, in workspace/$JOBNAME or on your slave in workspace/$JOBNAME), the files which will be created in _peass are saved temporarily. These can be deleted after the job has finished, since they are copied to peass-data