forked from CraftTweaker/CraftTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
141 lines (117 loc) · 4.58 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
#!/usr/bin/env groovy
def docsOutDir = 'docsOut'
def docsRepositoryUrl = '[email protected]:CraftTweaker/CraftTweaker-Documentation.git'
def docsRepositoryBranch = env.BRANCH_NAME
def gitSshCredentialsId = 'crt_git_ssh_key'
def botUsername = 'crafttweakerbot'
def botEmail = '[email protected]'
def documentationDir = 'CrafttweakerDocumentation'
def exportDirInRepo = 'docs_exported/crafttweaker'
def branchName = "1.16";
pipeline {
agent any
tools {
jdk "jdk8u292-b10"
}
environment {
ORG_GRADLE_PROJECT_secretFile = credentials('mod_build_secrets')
}
stages {
stage('Clean') {
steps {
echo 'Cleaning Project'
sh 'chmod +x gradlew'
sh './gradlew clean'
}
}
stage('Build') {
steps {
echo 'Building'
sh './gradlew build'
}
}
stage('Git Changelog') {
steps {
sh './gradlew genGitChangelog'
}
}
stage('Publish') {
stages {
stage('Updating Version') {
when {
branch '1.16'
}
steps {
script {
if (sh(script: "git log -1 --pretty=%B | fgrep -ie '[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 -ie '[skip deploy]' -e '[skip deploy]'", returnStatus: true) == 0) {
echo 'Skipping CurseForge due to [skip deploy]'
} else {
echo 'Deploying to CurseForge'
sh './gradlew curseforge'
}
}
}
}
stage('Exporting Documentation') {
when {
branch branchName
}
steps {
echo "Cloning Repository at Branch $docsRepositoryBranch"
dir(documentationDir) {
git credentialsId: gitSshCredentialsId, url: docsRepositoryUrl, branch: docsRepositoryBranch, 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 $docsRepositoryBranch"
}
}
}
}
}
}
}
post {
always {
archiveArtifacts 'build/libs/**.jar'
archiveArtifacts 'changelog.md'
}
}
}