-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
125 lines (117 loc) · 4.32 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
#!/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/jeitweaker'
def docCommitMessage = { -> "CI doc export for JeiTweaker build ${env.BUILD_NUMBER}\n\nMatches git commit ${env.GIT_COMMIT} on branch ${env.BRANCH_NAME}" }
def branchName = "1.18";
pipeline {
agent any
tools {
jdk "jdk-17.0.1"
}
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') {
when {
branch branchName
}
stages {
stage('Updating version') {
steps {
echo 'Updating version'
sh './gradlew updateVersionTracker'
}
}
stage('Deploy to Maven') {
steps {
echo 'Deploying to Maven'
sh './gradlew publish'
}
}
stage('Deploying to CurseForge') {
steps {
echo 'Deploying to CurseForge'
sh './gradlew curseforge'
}
}
stage('Exporting Documentation') {
when {
branch branchName
}
stages {
stage('Cloning Repository') {
steps {
echo 'Cloning documentation repository at "main" branch'
dir(documentationDir) {
git credentialsId: gitSshCredentialsId, url: docsRepositoryUrl, branch: 'main', changelog: false
}
}
}
stage('Clearing export') {
steps {
echo 'Clearing existing documentation export'
dir(documentationDir) {
sh "rm --recursive --force ./$exportDirInRepo"
}
}
}
stage('Moving documentation') {
steps {
echo 'Moving generated documentation to clone'
sh "mkdir --parents ./$documentationDir/$exportDirInRepo"
sh "mv ./$docsOutDir/* ./$documentationDir/$exportDirInRepo/"
}
}
stage('Publishing documentation') {
steps {
echo 'Committing documentation'
dir(documentationDir) {
sshagent([gitSshCredentialsId]) {
sh "git config user.name $botUsername"
sh "git config user.email $botEmail"
sh 'git add -A'
sh "git diff-index --quiet HEAD || git commit -m '${docCommitMessage()}'"
sh 'git push origin main'
}
}
}
}
}
}
}
}
}
post {
always {
archive 'build/libs/**.jar'
archive 'changelog.md'
}
}
options {
disableConcurrentBuilds()
}
}