Skip to content

Commit e35d4d7

Browse files
Merge pull request #3 from mnordsletten/master
Jenkins + conan improvements
2 parents ef61080 + 583dfc7 commit e35d4d7

2 files changed

Lines changed: 31 additions & 62 deletions

File tree

Jenkinsfile

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,60 @@
11
pipeline {
22
agent { label 'ubuntu-18.04' }
3-
3+
triggers { upstream( upstreamProjects: 'IncludeOS/IncludeOS/master, IncludeOS/IncludeOS/dev', threshold: hudson.model.Result.SUCCESS ) }
4+
options { checkoutToSubdirectory('src') }
45
environment {
56
CONAN_USER_HOME = "${env.WORKSPACE}"
67
PROFILE_x86_64 = 'clang-6.0-linux-x86_64'
7-
PROFILE_x86 = 'clang-6.0-linux-x86'
88
CPUS = """${sh(returnStdout: true, script: 'nproc')}"""
9-
CC = 'clang-6.0'
10-
CXX = 'clang++-6.0'
119
PACKAGE = 'diskbuilder'
1210
USER = 'includeos'
13-
CHAN = 'test'
11+
CHAN_LATEST = 'latest'
12+
CHAN_STABLE = 'stable'
1413
REMOTE = "${env.CONAN_REMOTE}"
1514
BINTRAY_CREDS = credentials('devops-includeos-user-pass-bintray')
15+
SRC = "${env.WORKSPACE}/src"
1616
}
1717

1818
stages {
1919
stage('Setup') {
2020
steps {
21+
sh script: "ls -A | grep -v src | xargs rm -r || :", label: "Clean workspace"
2122
sh script: "conan config install https://github.com/includeos/conan_config.git", label: "conan config install"
2223
}
2324
}
24-
stage('Pull Request pipeline') {
25-
when { changeRequest() }
26-
stages {
27-
stage('Build package') {
28-
steps {
29-
build_conan_package("$PROFILE_x86_64")
30-
}
31-
}
25+
stage('Build package') {
26+
steps {
27+
build_conan_package("$PROFILE_x86_64")
28+
script { VERSION = sh(script: "conan inspect -a version $SRC | cut -d ' ' -f 2", returnStdout: true).trim() }
3229
}
3330
}
34-
stage('Deploy package pipeline') {
35-
when {
36-
anyOf {
37-
branch 'master'
38-
}
39-
}
40-
stages {
41-
stage('Build Conan package') {
31+
stage('Upload to bintray') {
32+
parallel {
33+
stage('Latest release') {
34+
when { branch 'master' }
4235
steps {
43-
//TODO foreach profile ?
44-
build_conan_package("$PROFILE_x86_64")
36+
upload_package("$CHAN_LATEST")
4537
}
4638
}
47-
stage('Upload to bintray') {
39+
stage('Stable release') {
40+
when { buildingTag() }
4841
steps {
49-
sh script: """
50-
conan user -p $BINTRAY_CREDS_PSW -r $REMOTE $BINTRAY_CREDS_USR
51-
VERSION=\$(conan inspect -a version . | cut -d " " -f 2)
52-
conan upload --all -r $REMOTE $PACKAGE/\$VERSION@$USER/$CHAN
53-
""", label: "Upload to bintray"
42+
sh script: "conan copy --all $PACKAGE/$VERSION@$USER/$CHAN_LATEST $USER/$CHAN_STABLE", label: "Copy to stable channel"
43+
upload_package("$CHAN_STABLE")
5444
}
5545
}
5646
}
5747
}
5848
}
59-
post {
60-
cleanup {
61-
sh script: """
62-
VERSION=\$(conan inspect -a version . | cut -d " " -f 2)
63-
conan remove $PACKAGE/\$VERSION@$USER/$CHAN -f || echo 'Could not remove. This does not fail the pipeline'
64-
""", label: "Cleaning up and removing conan package"
65-
}
66-
}
6749
}
6850

69-
7051
def build_conan_package(String profile) {
71-
sh script: "conan create . $USER/$CHAN -pr ${profile}", label: "Build with profile: $profile"
52+
sh script: "conan create $SRC $USER/$CHAN_LATEST -pr ${profile}", label: "Build with profile: $profile"
53+
}
54+
55+
def upload_package(String channel) {
56+
sh script: """
57+
conan user -p $BINTRAY_CREDS_PSW -r $REMOTE $BINTRAY_CREDS_USR
58+
conan upload --all -r $REMOTE $PACKAGE/$VERSION@$USER/$channel
59+
""", label: "Upload to bintray"
7260
}

conanfile.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
import os
2-
from conans import ConanFile,tools,CMake
3-
4-
def get_version():
5-
git = tools.Git()
6-
try:
7-
prev_tag = git.run("describe --tags --abbrev=0")
8-
commits_behind = int(git.run("rev-list --count %s..HEAD" % (prev_tag)))
9-
# Commented out checksum due to a potential bug when downloading from bintray
10-
#checksum = git.run("rev-parse --short HEAD")
11-
if prev_tag.startswith("v"):
12-
prev_tag = prev_tag[1:]
13-
if commits_behind > 0:
14-
prev_tag_split = prev_tag.split(".")
15-
prev_tag_split[-1] = str(int(prev_tag_split[-1]) + 1)
16-
output = "%s-%d" % (".".join(prev_tag_split), commits_behind)
17-
else:
18-
output = "%s" % (prev_tag)
19-
return output
20-
except:
21-
return '0.0.0'
22-
2+
from conans import ConanFile, python_requires, CMake
3+
conan_tools = python_requires("conan-tools/[>=1.0.0]@includeos/stable")
234

245
class DiskbuilderConan(ConanFile):
256
settings="os_build","arch_build"
267
name = "diskbuilder"
27-
version = get_version()
8+
version = conan_tools.git_get_semver()
289
license = "Apache-2.0"
2910
description = "A tool to create an IncludeOS binary filesystem image"
3011
scm = {
@@ -36,7 +17,7 @@ class DiskbuilderConan(ConanFile):
3617
generators='cmake'
3718
no_copy_source=True
3819
default_user="includeos"
39-
default_channel="test"
20+
default_channel="latest"
4021

4122
def _cmake_configure(self):
4223
cmake=CMake(self)

0 commit comments

Comments
 (0)