This repository has been archived by the owner on Mar 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
68 lines (65 loc) · 2.15 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
pipeline {
agent { label 'ubuntu-18.04' }
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 = 'mender'
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('Build example') {
steps {
dir('build_example') {
sh script: "conan install $SRC/example -pr $PROFILE_x86_64", label: "conan_install"
sh script: ". ./activate.sh; cmake $SRC/example",label: "cmake configure"
sh script: "make -j $CPUS", label: "building example"
}
}
}
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"
}