forked from CraftTweaker/CraftTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
155 lines (133 loc) · 5.2 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
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
#!/usr/bin/env groovy
def docsOutDir = 'docsOut'
def docsRepositoryUrl = '[email protected]:CraftTweaker/CraftTweaker-Documentation.git'
def gitSshCredentialsId = 'crt_git_ssh_key'
def botUsername = 'crafttweakerbot'
def botEmail = '[email protected]'
def documentationDir = 'CrafttweakerDocumentation'
def exportDirInRepo = 'docs_exported/1.18/crafttweaker'
def branchName = "1.18";
pipeline {
agent any
tools {
jdk "jdk-17.0.1"
}
environment {
curseforgeApiToken = credentials('curseforge_token')
discordCFWebhook = credentials('discord_cf_webhook')
versionTrackerKey = credentials('version_tracker_key')
versionTrackerAPI = credentials('version_tracker_api')
}
stages {
stage('Clean') {
steps {
echo 'Cleaning Project'
sh 'chmod +x gradlew'
sh './gradlew clean'
sh "rm -rf $docsOutDir"
}
}
stage('Build') {
steps {
echo 'Building'
sh './gradlew build'
}
}
stage('Test') {
steps {
echo 'Running tests'
sh './gradlew check gameTest'
}
}
stage('Git Changelog') {
steps {
sh './gradlew genGitChangelog'
}
}
stage('Publish') {
stages {
stage('Updating Version') {
when {
branch branchName
}
steps {
script {
if (sh(script: "git log -1 --pretty=%B | fgrep -i -e '[skip deploy]' -e '[skip-deploy]'", returnStatus: true) == 0) {
echo 'Skipping Update Version due to [skip deploy]'
} else {
echo 'Updating Version'
sh './gradlew updateVersionTracker'
}
}
}
}
stage('Deploying to Maven') {
when {
branch branchName
}
steps {
echo 'Deploying to Maven'
sh './gradlew publish'
}
}
stage('Deploying to CurseForge') {
when {
branch branchName
}
steps {
script {
if (sh(script: "git log -1 --pretty=%B | fgrep -i -e '[skip deploy]' -e '[skip-deploy]'", returnStatus: true) == 0) {
echo 'Skipping CurseForge due to [skip deploy]'
} else {
echo 'Deploying to CurseForge'
sh './gradlew publishCurseForge postDiscord'
}
}
}
}
stage('Exporting Documentation') {
when {
branch branchName
}
steps {
echo "Cloning Repository at Branch main"
dir(documentationDir) {
git credentialsId: gitSshCredentialsId, url: docsRepositoryUrl, branch: "main", changelog: false
}
echo "Clearing existing Documentation export"
dir(documentationDir) {
sh "rm --recursive --force ./$exportDirInRepo"
}
echo "Moving Generated Documentation to Local Clone"
sh "mkdir --parents ./$documentationDir/$exportDirInRepo"
sh "mv ./$docsOutDir/* ./$documentationDir/$exportDirInRepo/"
echo "Committing and Pushing to the repository"
dir(documentationDir) {
sshagent([gitSshCredentialsId]) {
sh "git config user.name $botUsername"
sh "git config user.email $botEmail"
sh 'git add -A'
//Either nothing to commit, or we create a commit
sh "git diff-index --quiet HEAD || git commit -m 'CI Doc export for build ${env.BRANCH_NAME}-${env.BUILD_NUMBER}\n\nMatches git commit ${env.GIT_COMMIT}'"
sh "git push origin main"
}
}
}
}
}
}
}
post {
always {
archiveArtifacts 'Common/build/libs/**.jar'
archiveArtifacts 'Fabric/build/libs/**.jar'
archiveArtifacts 'Forge/build/libs/**.jar'
junit 'ZenCode/ScriptingExample/build/test-results/**/*.xml'
junit 'Fabric/run_game_test/game-test-results.xml'
junit 'Forge/run_game_test/game-test-results.xml'
}
}
options {
disableConcurrentBuilds()
}
}