File: Jenkinsfile

package info (click to toggle)
ossim 2.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 29,740 kB
  • sloc: cpp: 383,170; ansic: 15,201; sh: 2,311; lex: 183; xml: 141; sql: 78; makefile: 77; csh: 6
file content (165 lines) | stat: -rw-r--r-- 6,943 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
properties([
    parameters ([
        string(name: 'BUILD_NODE', defaultValue: 'ossim-build', description: 'The build node to run on'),
        string(name: 'MAKE_VERBOSE', defaultValue: 'VERBOSE=true', description: ''),
        booleanParam(name: 'BUILD_WITH_FORTIFY', defaultValue: false, description: 'Check to build and scan source using HP Fortify tool'),
        booleanParam(name: 'SCAN_WITH_SONARQUBE', defaultValue: false, description: 'Check to perform SonarQube analysis'),
        booleanParam(name: 'CLEAN_WORKSPACE', defaultValue: true, description: 'Clean the workspace at the end of the run')
    ]),
    pipelineTriggers([
            [$class: "GitHubPushTrigger"]
    ]),
    [$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/ossimlabs/ossim'],
    buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '3', daysToKeepStr: '', numToKeepStr: '20')),
    disableConcurrentBuilds()
])

node ("${BUILD_NODE}"){

    try {
        stage( "Download Artifacts" ) {
            env.OPENCV_HOME = "${env.WORKSPACE}/opencv-3.2-minimal-install"
            withCredentials([string(credentialsId: 'o2-artifact-project', variable: 'o2ArtifactProject')]) {
                step ([$class: "CopyArtifact",
                    projectName: o2ArtifactProject,
                    filter: "common-variables.groovy",
                    flatten: true])
            }

            dir( "${ env.WORKSPACE }" ) {
                step ([$class: "CopyArtifact",
                    projectName: "kakadu-build",
                    filter: "kakadu.tgz",
                    flatten: true])
                    sh "tar xvfz kakadu.tgz"

                step ([$class: "CopyArtifact",
                    projectName: "opencv-build",
                    filter: "opencv-3.2-minimal-install.tgz",
                    flatten: true,
                    target: "${ env.WORKSPACE }/opencv-3.2-minimal-install"])
                    sh """
                        pushd opencv-3.2-minimal-install
                        tar xvfz opencv-3.2-minimal-install.tgz
                        popd
                    """
            }

            load "common-variables.groovy"
        }

        stage( "Checkout" ) {
            dir( "ossim" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-video" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim-video.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-planet" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim-planet.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-gui" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim-gui.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-oms" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim-oms.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-plugins" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim-plugins.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-wms" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PUBLIC_SERVER_URL }/ossim-wms.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
            dir( "ossim-private" ) {
                git branch: "$BRANCH_NAME",
                url: "${ GIT_PRIVATE_SERVER_URL }/ossim-private.git",
                credentialsId: "${ CREDENTIALS_ID }"
            }
        }

        stage( "Build" ) {
            dir( "${ env.WORKSPACE }" ) {
                sh """
                    rm -rf ${ env.WORKSPACE }/build/CMakeCache.txt
                    export PATH=${ PATH }:/opt/HPE_Security/Fortify_SCA_and_Apps_17.20/bin
                    ${ env.WORKSPACE }/ossim/scripts/ossim-build.sh
                    ${ env.WORKSPACE }/ossim/scripts/ossim-install.sh
                """
            }
        }

        stage ( "Publish Nexus" ) {
            withCredentials([[$class: 'UsernamePasswordMultiBinding',
                credentialsId: 'nexusCredentials',
                usernameVariable: 'REPOSITORY_MANAGER_USER',
                passwordVariable: 'REPOSITORY_MANAGER_PASSWORD']]) {
                    dir( "${ env.WORKSPACE }" ) {
                        sh "${ env.WORKSPACE }/ossim/scripts/oms-deploy.sh"
                    }
            }
        }

        stage( "Archive" ) {
            dir( "${ env.WORKSPACE }" ) {
                sh "tar cvfz ossim-install.tgz install"
            }
            dir( "${ env.WORKSPACE }/artifacts" ) {
                sh "mv ${ env.WORKSPACE }/ossim-install.tgz ."
                sh "cp ${ env.WORKSPACE }/ossim-oms/lib/joms-*.jar ."
            }
            archiveArtifacts "artifacts/*"
        }

        if (SCAN_WITH_SONARQUBE == "true" ) {
            stage( 'SonarQube analysis' ) {
                withSonarQubeEnv( "${ SONARQUBE_NAME }" ) {
                    // requires SonarQube Scanner for Gradle 2.1+
                    // It's important to add --info because of SONARJNKNS-281
                    sh "sonar-scanner"
                }
            }
        }

        if ( BUILD_WITH_FORTIFY == "true" ) {
            stage( 'Fortify SCA' ) {
                dir( "${ env.WORKSPACE }/build" ) {
                    sh """ 
                        export PATH=${ PATH }:/opt/HPE_Security/Fortify_SCA_and_Apps_17.20/bin
                        sourceanalyzer -64 -b ossimlabs -scan -f fortifyResults-ossim.fpr
                    """
                    archiveArtifacts "fortifyResults-ossim.fpr"
                    withCredentials([[$class: 'UsernamePasswordMultiBinding',
                            credentialsId: 'fortifyCredentials',
                            usernameVariable: 'HP_FORTIFY_USERNAME',
                            passwordVariable: 'HP_FORTIFY_PASSWORD']]) {
                        sh """
                            export PATH=${ PATH }:/opt/HPE_Security/Fortify_SCA_and_Apps_17.20/bin
                            fortifyclient -url ${ HP_FORTIFY_URL } -user "${ HP_FORTIFY_USERNAME }" -password "${ HP_FORTIFY_PASSWORD }" uploadFPR -file fortifyResults-ossim.fpr -project ossim -version 1.0
                        """
                    }
                }
            }
        }
    }
    finally {
        stage( "Clean Workspace" ) {
            if ( "${ CLEAN_WORKSPACE }" == "true" )
                step([$class: 'WsCleanup'])
        }
    }

}