forked from CraftTweaker/CraftTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
109 lines (89 loc) · 3.46 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
#!/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'
pipeline {
agent any
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') {
steps {
echo 'Updating Version'
sh './gradlew updateVersionTracker'
}
}
stage('Deploying to Maven') {
steps {
echo 'Deploying to Maven'
sh './gradlew publish'
}
}
stage('Deploying to CurseForge (Disabled)') {
steps {
echo 'Deploying to CurseForge'
sh './gradlew curseforge'
}
}
stage('Exporting Documentation (Disabled)') {
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'
}
}
}