Jenkinsfile 1.54 KB
Newer Older
Dominik Vayhinger's avatar
Dominik Vayhinger committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
pipeline {
    environment {
        registry = "hftstuttgart/modocot-backend"
        //wie hier lösen?
        registryCredential = 'Dockerhub'
        dockerImage = ''
    }
    agent any
    tools {
        jdk 'Java11'
        maven 'Maven_Home'
    }
    stages {
        stage('Checkout') {
            steps {
                echo 'Checkout Repository..'
                git branch: 'master',
                // Cred löschen da final repo public
                credentialsId: '1651d97b-1744-4af3-bdd0-0fc9a5a90ef7',
                //url auf finales repo anpassen
                url: 'https://gitlab.rz.hft-stuttgart.de/swp2-lc/MoJEC-Backend.git'
            }
        }
        stage('Build') {
            steps {
                echo 'Maven Build..'
                sh 'mvn clean package -DskipTests=false'
            }
        }
        stage('Docker Build..') {
            steps{
                script {
                    dockerImage = docker.build registry + ":latest"
                }
            }
        }
        stage('Push to Dockerhub..') {
                    steps{
                        script {
                            docker.withRegistry( '', registryCredential ) {
                                dockerImage.push()
                            }
                        }
                    }
                }

        stage('ShellScript') {
            steps {
                echo 'Exectue Shellscript..'
                sh 'chmod 744 restart_modocot_backend.sh && ./restart_modocot_backend.sh'
            }
        }
    }
}