Skip to content
Jenkinsfile 1.68 KiB
Newer Older
Luca Verardo's avatar
Luca Verardo committed
pipeline {
    agent {
        docker {
            image 'maven:3-alpine'
        }
    }
Luca Verardo's avatar
Luca Verardo committed
    stages{
        stage('Configure') {
            env.PATH = "${tool 'maven-3.3.9'}/bin:${env.PATH}"
            version = '1.0.' + env.BUILD_NUMBER
            currentBuild.displayName = version
Luca Verardo's avatar
Luca Verardo committed

Luca Verardo's avatar
Luca Verardo committed
            properties([
                    buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
                    [$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://http://github.com/zegorax/mentorarc/'],
                    pipelineTriggers([[$class: 'GitHubPushTrigger']])
                ])
        }
Zegorax's avatar
Zegorax committed

Luca Verardo's avatar
Luca Verardo committed
        stage('Checkout') {
            git 'https://http://github.com/zegorax/mentorarc'
        }
Zegorax's avatar
Zegorax committed

Luca Verardo's avatar
Luca Verardo committed
        stage('Version') {
            sh "echo \'\ninfo.build.version=\'$version >> src/main/resources/application.properties || true"
            sh "mvn -B -V -U -e versions:set -DnewVersion=$version"
        }
Zegorax's avatar
Zegorax committed

Luca Verardo's avatar
Luca Verardo committed
        stage('Build') {
            sh 'mvn -B -V -U -e clean package'
        }
Luca Verardo's avatar
Luca Verardo committed

Luca Verardo's avatar
Luca Verardo committed
        stage('Archive') {
            junit allowEmptyResults: true, testResults: '**/target/**/TEST*.xml'
        }
Zegorax's avatar
Zegorax committed

Luca Verardo's avatar
Luca Verardo committed
        stage('Deploy') {
            // Depends on the 'Credentials Binding Plugin'
            // (https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin)
            withCredentials([[$class          : 'UsernamePasswordMultiBinding', credentialsId: 'cloudfoundry',
                            usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
                sh '''
                    echo hello
                    echo test
                '''
            }
Zegorax's avatar
Zegorax committed
        }
    }
Luca Verardo's avatar
Luca Verardo committed
}