-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
60 lines (57 loc) · 1.95 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
pipeline {
agent { label 'ubuntu-18.04' }
triggers { upstream( upstreamProjects: 'IncludeOS/IncludeOS/master, IncludeOS/IncludeOS/dev', threshold: hudson.model.Result.SUCCESS ) }
options { checkoutToSubdirectory('src') }
environment {
CONAN_USER_HOME = "${env.WORKSPACE}"
PROFILE_x86_64 = 'clang-6.0-linux-x86_64'
CPUS = """${sh(returnStdout: true, script: 'nproc')}"""
PACKAGE = 'NaCl'
USER = 'includeos'
CHAN_LATEST = 'latest'
CHAN_STABLE = 'stable'
REMOTE = "${env.CONAN_REMOTE}"
BINTRAY_CREDS = credentials('devops-includeos-user-pass-bintray')
SRC = "${env.WORKSPACE}/src"
}
stages {
stage('Setup') {
steps {
sh script: "ls -A | grep -v src | xargs rm -r || :", label: "Clean workspace"
sh script: "conan config install https://github.com/includeos/conan_config.git", label: "conan config install"
}
}
stage('Build package') {
steps {
build_conan_package("$PROFILE_x86_64")
script { VERSION = sh(script: "conan inspect -a version $SRC | cut -d ' ' -f 2", returnStdout: true).trim() }
}
}
stage('Upload to bintray') {
parallel {
stage('Latest release') {
when { branch 'master' }
steps {
upload_package("$CHAN_LATEST")
}
}
stage('Stable release') {
when { buildingTag() }
steps {
sh script: "conan copy --all $PACKAGE/$VERSION@$USER/$CHAN_LATEST $USER/$CHAN_STABLE", label: "Copy to stable channel"
upload_package("$CHAN_STABLE")
}
}
}
}
}
}
def build_conan_package(String profile) {
sh script: "conan create $SRC $USER/$CHAN_LATEST -pr ${profile}", label: "Build with profile: $profile"
}
def upload_package(String channel) {
sh script: """
conan user -p $BINTRAY_CREDS_PSW -r $REMOTE $BINTRAY_CREDS_USR
conan upload --all -r $REMOTE $PACKAGE/$VERSION@$USER/$channel
""", label: "Upload to bintray"
}