forked from MovingBlocks/Terasology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (47 loc) · 2.52 KB
/
Jenkinsfile
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
// Minor housekeeping logic
boolean specialBranch = env.BRANCH_NAME.equals("master") || env.BRANCH_NAME.equals("develop")
// String to use in a property that determines artifact pruning (has to be a String not a number)
String artifactBuildsToKeep = "1"
if (specialBranch) {
artifactBuildsToKeep = "10"
}
properties([
// Needed due to the Copy Artifact plugin deciding to implement an obnoxious security feature that can't simply be turned off
copyArtifactPermission('*'),
// Flag for Jenkins to discard attached artifacts after x builds
buildDiscarder(logRotator(artifactNumToKeepStr: artifactBuildsToKeep))
])
// Main pipeline definition
node ("heavy-java") {
stage('Checkout') {
echo "Going to check out the things !"
checkout scm
sh 'chmod +x gradlew'
}
stage('Build') {
// Jenkins sometimes doesn't run Gradle automatically in plain console mode, so make it explicit
sh './gradlew --console=plain clean extractConfig extractNatives distForLauncher'
archiveArtifacts 'gradlew, gradle/wrapper/*, templates/build.gradle, config/**, facades/PC/build/distributions/Terasology.zip, build/resources/main/org/terasology/version/versionInfo.properties, natives/**, buildSrc/src/**, buildSrc/*.kts'
}
stage('Publish') {
if (specialBranch) {
withCredentials([usernamePassword(credentialsId: 'artifactory-gooey', usernameVariable: 'artifactoryUser', passwordVariable: 'artifactoryPass')]) {
sh './gradlew --console=plain -Dorg.gradle.internal.publish.checksums.insecure=true publish -PmavenUser=${artifactoryUser} -PmavenPass=${artifactoryPass}'
}
} else {
println "Running on a branch other than 'master' or 'develop' bypassing publishing"
}
}
stage('Analytics') {
sh "./gradlew --console=plain check spotbugsmain javadoc"
}
stage('Record') {
junit testResults: '**/build/test-results/test/*.xml', allowEmptyResults: true
recordIssues tool: javaDoc()
step([$class: 'JavadocArchiver', javadocDir: 'engine/build/docs/javadoc', keepAll: false])
recordIssues tool: checkStyle(pattern: '**/build/reports/checkstyle/*.xml')
recordIssues tool: spotBugs(pattern: '**/build/reports/spotbugs/main/*.xml', useRankAsPriority: true)
recordIssues tool: pmdParser(pattern: '**/build/reports/pmd/*.xml')
recordIssues tool: taskScanner(includePattern: '**/*.java,**/*.groovy,**/*.gradle', lowTags: 'WIBNIF', normalTags: 'TODO', highTags: 'ASAP')
}
}