Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add client build artifacts and run packr #55

Merged
merged 17 commits into from
Feb 15, 2019
Merged
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:18.04

COPY sources-18.04-azure.list /etc/apt/sources.list

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
patchelf \
git \
python3-setuptools \
python3-wheel \
python3-pip \
golang-go \
go-dep \
&& rm -rf /var/lib/apt/lists/*

# Install packr
ENV GOPATH=/go
ENV PATH=${GOPATH}/bin:${PATH}
RUN go get -v -u github.com/gobuffalo/packr/packr

# Install Conan package manager
RUN pip3 install conan
3 changes: 3 additions & 0 deletions .dockerfiles/sources-18.04-azure.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
deb http://azure.archive.ubuntu.com/ubuntu bionic main universe multiverse
deb http://azure.archive.ubuntu.com/ubuntu bionic-security main
deb http://azure.archive.ubuntu.com/ubuntu bionic-updates main universe multiverse
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -17,5 +17,9 @@ cse-server-go
.idea

# Client build directory and artifact
target/
resources/public/js/compiled/app.js
resources/public/js/compiled/app.js

# Dep/packr
Gopkg.lock
resources/
vendor/
180 changes: 154 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -2,57 +2,185 @@ pipeline {
agent none

triggers {
upstream(upstreamProjects: 'open-simulation-platform/cse-core/master', threshold: hudson.model.Result.SUCCESS)
upstream(
upstreamProjects: 'open-simulation-platform/cse-core/feature/151-build-conan-linux-binaries, open-simulation-platform/cse-client/master',
threshold: hudson.model.Result.SUCCESS)
}

options { checkoutToSubdirectory('src/cse-server-go') }

stages {
stage('Build server') {
parallel {
stage('Build on Windows') {
stage('Windows') {
agent { label 'windows' }

environment {
GOPATH = "${WORKSPACE}"
GOBIN = "${WORKSPACE}/bin"
PATH = "${env.MINGW_HOME}/bin;${GOBIN};${env.PATH}"
CGO_CFLAGS = "-I${WORKSPACE}/src/windows/debug/include"
CGO_LDFLAGS = "-L${WORKSPACE}/src/windows/debug/bin -lcsecorec"
CGO_CFLAGS = "-I${WORKSPACE}/src/cse-server-go/include"
CGO_LDFLAGS = "-L${WORKSPACE}/src/cse-server-go/dist/bin -lcsecorec"
CONAN_USER_HOME = "${env.BASE}/conan-repositories/${env.EXECUTOR_NUMBER}"
CONAN_USER_HOME_SHORT = "${env.CONAN_USER_HOME}"
OSP_CONAN_CREDS = credentials('jenkins-osp-conan-creds')
}

tools {
go 'go-1.11'
//'com.cloudbees.jenkins.plugins.customtools.CustomTool' 'mingw-w64' awaiting fix in customToolsPlugin
}

steps {
sh 'echo Building on Windows'

copyArtifacts(
projectName: 'open-simulation-platform/cse-core/master',
filter: 'windows/debug/**/*',
target: 'src')

dir ("${GOBIN}") {
sh 'curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh'
stages {
stage ('Get dependencies') {
steps {
dir ("${GOBIN}") {
sh 'curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh'
}
copyArtifacts(
projectName: 'open-simulation-platform/cse-client/master',
filter: 'resources/public/**/*',
target: 'src/cse-server-go')

dir ('src/cse-server-go') {
sh 'go get github.com/gobuffalo/packr/packr'
sh 'conan remote add osp https://osp-conan.azurewebsites.net/artifactory/api/conan/conan-local --force'
sh 'conan user -p $OSP_CONAN_CREDS_PSW -r osp $OSP_CONAN_CREDS_USR'
sh 'conan install . -s build_type=Release'
sh 'dep ensure'
}
}
}
stage ('Packr') {
steps {
dir ('src/cse-server-go') {
sh 'go clean -cache'
sh 'packr build -v'
}
}
}
stage ('Prepare dist') {
steps {
dir ('src/cse-server-go/dist/bin') {
sh 'cp -rf ../../cse-server-go.exe .'
}
}
}
stage ('Zip dist') {
when {
not { buildingTag() }
}
steps {
dir ('src/cse-server-go/dist') {
zip (
zipFile: "cse-server-go-win64.zip",
archive: true
)
}
}
}
dir ('src/cse-server-go') {
sh 'dep ensure'
sh 'go build'
stage ('Zip release') {
when { buildingTag() }
steps {
dir ('src/cse-server-go/dist') {
zip (
zipFile: "cse-server-go-${env.TAG_NAME}-win64.zip",
archive: true
)
}
}
}
}
post {
cleanup {
dir('src/cse-server-go/dist') {
deleteDir();
}
}
}
}
stage ('Build on Linux') {
agent { label 'linux' }

tools {
go 'go-1.11'
stage ('Linux') {
agent {
dockerfile {
filename 'Dockerfile'
dir 'src/cse-server-go/.dockerfiles'
label 'linux && docker'
args '-v ${HOME}/jenkins_slave/conan-repositories/${EXECUTOR_NUMBER}:/conan_repo'
}
}

steps {
sh 'echo building on Linux'
sh 'go version'
environment {
GOPATH = "${WORKSPACE}"
CGO_CFLAGS = "-I${WORKSPACE}/src/cse-server-go/include"
CGO_LDFLAGS = "-L${WORKSPACE}/src/cse-server-go/dist/lib -lcsecorec -Wl,-rpath,\$ORIGIN/../lib"
CONAN_USER_HOME = '/conan_repo'
CONAN_USER_HOME_SHORT = 'None'
OSP_CONAN_CREDS = credentials('jenkins-osp-conan-creds')
}

stages {
stage ('Get dependencies') {
steps {
copyArtifacts(
projectName: 'open-simulation-platform/cse-client/master',
filter: 'resources/public/**/*',
target: 'src/cse-server-go')

dir ('src/cse-server-go') {
sh 'conan remote add osp https://osp-conan.azurewebsites.net/artifactory/api/conan/conan-local --force'
sh 'conan user -p $OSP_CONAN_CREDS_PSW -r osp $OSP_CONAN_CREDS_USR'
sh 'conan install . -s build_type=Release -s compiler.libcxx=libstdc++11'
sh 'patchelf --set-rpath \'$ORIGIN/../lib\' dist/lib/*'
sh 'dep ensure'
}
}
}
stage ('Packr') {
steps {
dir ('src/cse-server-go') {
sh 'go clean -cache'
sh 'packr build -v'
}
}
}
stage ('Prepare dist') {
steps {
dir ('src/cse-server-go/dist/bin') {
sh 'cp -rf ../../cse-server-go .'
}
}
}
stage ('Zip dist') {
when {
not { buildingTag() }
}
steps {
dir ('src/cse-server-go/dist') {
zip (
zipFile: "cse-server-go-linux.tar.gz",
archive: true
)
}
}
}
stage ('Zip release') {
when { buildingTag() }
steps {
dir ('src/cse-server-go/dist') {
zip (
zipFile: "cse-server-go-${env.TAG_NAME}-linux.tar.gz",
archive: true
)
}
}
}
}
post {
cleanup {
dir('src/cse-server-go/dist') {
deleteDir();
}
}
}
}
}
26 changes: 26 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[generators]
virtualbuildenv

[requires]
cse-core/0.1.0@osp/feature_151-build-conan-linux-binaries

[imports]
include, cse.h -> ./include

bin, boost_context*.dll -> ./dist\bin
bin, boost_fiber*.dll -> ./dist\bin
bin, boost_filesystem*.dll -> ./dist\bin
bin, boost_log*.dll -> ./dist\bin
bin, boost_system*.dll -> ./dist\bin
bin, boost_thread*.dll -> ./dist\bin
bin, cse*.dll -> ./dist\bin
bin, zip.dll -> ./dist\bin

lib, libboost_context.so.* -> ./dist/lib
lib, libboost_fiber.so.* -> ./dist/lib
lib, libboost_filesystem.so.* -> ./dist/lib
lib, libboost_log.so.* -> ./dist/lib
lib, libboost_system.so.* -> ./dist/lib
lib, libboost_thread.so* -> ./dist/lib
lib, libcse*.so -> ./dist/lib
lib, libzip.so* -> ./dist/lib