Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Jenkinsfile 9.22 KiB
//////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010, 2022 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available
// under the terms of the MIT License which is available at
// https://opensource.org/licenses/MIT
//
// SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////

pipeline {
    agent {
        // The 'centos-7' pod template allows UI tests.
        kubernetes {
            inheritFrom 'centos-7'
        }
    }

    tools {
        jdk 'openjdk-jdk11-latest'
        maven 'apache-maven-3.8.1'
    }

    options {
        buildDiscarder(logRotator(
            // Number of builds to keep.
            numToKeepStr: '5',

            // Number of builds for which to keep the artifacts.
            artifactNumToKeepStr: '5',

            // Number of days to keep builds.
            daysToKeepStr: env.BRANCH_NAME ==~ /master/ ? '7' :             // master
                           env.BRANCH_NAME ==~ /develop/ ? '1000' :         // develop
                           env.TAG_NAME ==~ /v[0-9]+\\.[0-9]+.*/ ?  '120' : // release tags
                           '30',                                            // other branches and merge requests

            // Number of days to keep artifacts of builds.
            artifactDaysToKeepStr: env.BRANCH_NAME ==~ /master/ ? '7' :            // master
                                   env.BRANCH_NAME ==~ /develop/ ? '1000' :        // develop
                                   env.TAG_NAME ==~ /v[0-9]+\\.[0-9]+.*/ ?  '30' : // release tags
                                   '30',                                           // other branches and merge requests
        ))
        timeout(time: 1, unit: 'HOURS')
        timestamps()
    }

    stages {
        stage('Build & Test') {
            steps {
                wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
                    sh '''
                        # Print versions.
                        java -version
                        mvn -version
                        git --version

                        # Print environment.
                        printenv

                        # Check license headers are present for all files, where relevant.
                        ./misc/license-header/license-header-check.bash

                        # Get Git last commit date.
                        GIT_DATE_EPOCH=$(git log -1 --format=%cd --date=raw | cut -d ' ' -f 1)
                        GIT_DATE=$(date -d @$GIT_DATE_EPOCH -u +%Y%m%d-%H%M%S)