Skip to content

Commit d539d40

Browse files
committed
Don't run any publish steps if it's not a release branch
1 parent 4b5ed74 commit d539d40

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

Jenkinsfile

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env groovy
22
// noinspection GroovyAssignabilityCheck
33

4+
RELEASE_BRANCHES = ["main", "1.19"]
5+
46
pipeline {
57
agent any
68
tools {
@@ -40,44 +42,51 @@ pipeline {
4042
sh "./gradlew build"
4143
}
4244
}
43-
stage("Publish: Maven") {
44-
steps {
45-
sh "./gradlew publish"
46-
}
47-
}
48-
stage("Publish: GitHub") {
49-
when {
50-
expression { return params.PUBLISH_GITHUB }
51-
}
52-
environment {
53-
GITHUB_TOKEN = credentials("github-release-pat")
54-
GITHUB_REPOSITORY = "object-Object/HexDebug"
55-
GITHUB_SHA = "${env.GIT_COMMIT}"
56-
}
57-
steps {
58-
sh "./gradlew publishGithub"
59-
}
60-
}
61-
stage("Publish: CurseForge") {
45+
stage("Publish") {
6246
when {
63-
expression { return params.PUBLISH_CURSEFORGE }
64-
}
65-
environment {
66-
CURSEFORGE_TOKEN = credentials("curseforge-token")
47+
expression { env.BRANCH_NAME in RELEASE_BRANCHES }
6748
}
68-
steps {
69-
sh "./gradlew publishCurseforge"
70-
}
71-
}
72-
stage("Publish: Modrinth") {
73-
when {
74-
expression { return params.PUBLISH_MODRINTH }
75-
}
76-
environment {
77-
MODRINTH_TOKEN = credentials("modrinth-pat")
78-
}
79-
steps {
80-
sh "./gradlew publishModrinth"
49+
stages {
50+
stage("Publish: Maven") {
51+
steps {
52+
sh "./gradlew publish"
53+
}
54+
}
55+
stage("Publish: GitHub") {
56+
when {
57+
expression { params.PUBLISH_GITHUB }
58+
}
59+
environment {
60+
GITHUB_TOKEN = credentials("github-release-pat")
61+
GITHUB_REPOSITORY = "object-Object/HexDebug"
62+
GITHUB_SHA = "${env.GIT_COMMIT}"
63+
}
64+
steps {
65+
sh "./gradlew publishGithub"
66+
}
67+
}
68+
stage("Publish: CurseForge") {
69+
when {
70+
expression { params.PUBLISH_CURSEFORGE }
71+
}
72+
environment {
73+
CURSEFORGE_TOKEN = credentials("curseforge-token")
74+
}
75+
steps {
76+
sh "./gradlew publishCurseforge"
77+
}
78+
}
79+
stage("Publish: Modrinth") {
80+
when {
81+
expression { params.PUBLISH_MODRINTH }
82+
}
83+
environment {
84+
MODRINTH_TOKEN = credentials("modrinth-pat")
85+
}
86+
steps {
87+
sh "./gradlew publishModrinth"
88+
}
89+
}
8190
}
8291
}
8392
}

0 commit comments

Comments
 (0)