-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
executable file
·73 lines (65 loc) · 2.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
#!groovy
def branchName = env.BRANCH_NAME
def credentialsId = 'b910c0f1-6dac-4947-9152-7e1b0b7bc5ec'
def gitRepo = 'git@github.com:Bluehexagon433/template-library.git'
def repoAlias = "origin"
node('apk-builder') {
stage('Checkout Source Code') {
//branch name from Jenkins environment variables
echo "My branch is: ${env.BRANCH_NAME}"
checkout(
[
$class : 'GitSCM',
branches : [
[
name: "$env.BRANCH_NAME"
]
],
browser : [
$class : 'GithubWeb',
repoUrl: 'https://github.com/Bluehexagon433/template-library'
],
doGenerateSubmoduleConfigurations: false,
extensions : [
[
$class: 'LocalBranch', localBranch: "$env.BRANCH_NAME"
]
],
submoduleCfg : [
],
userRemoteConfigs : [
[
credentialsId: "$credentialsId", name: "$repoAlias", url: "$gitRepo"
]
]
]
)
}
stage('Clean') {
sh './gradlew :library:clean'
}
// Pipeline for develop and feature branches
if (branchName == 'develop') {
runDevelopPipeline()
} else if (branchName == 'master') {
runMasterPipeline()
} else if (branchName.startsWith('feature/')) {
runDevelopPipeline()
}
}
def runDevelopPipeline() {
stage('Assemble Debug') {
sh "./gradlew :library:assembleDebug"
}
stage('upload to libs-snapshot-local') {
sh "./gradlew :library:publish"
}
}
def runMasterPipeline() {
stage('Assemble Release') {
sh "./gradlew :library:assembleRelease"
}
stage('upload to libs-release-local') {
sh "./gradlew :library:publish"
}
}