Add a Jenkinsfile (and some refactors) (#6)

This commit is contained in:
Cassandra
2019-08-29 17:05:53 +02:00
committed by GitHub
parent 2778b8e90e
commit 1ebd0a523f
5 changed files with 135 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ FROM golang:1-alpine AS build
RUN apk add git RUN apk add git
RUN mkdir -p /go/src/github.com/Pandentia RUN mkdir -p /go/src/github.com/Pandentia
COPY ./ /go/src/github.com/Pandentia/protoplex COPY ./ /go/src/github.com/Pandentia/protoplex
RUN go get github.com/Pandentia/protoplex RUN go get github.com/Pandentia/protoplex/cmd/protoplex
# deploy # deploy
FROM alpine:latest FROM alpine:latest

127
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,127 @@
String buildCommand = '''
export CGO_ENABLED=0
export GOOS=$(echo ${STAGE_NAME} | cut -d '/' -f 1)
export GOARCH=$(echo ${STAGE_NAME} | cut -d '/' -f 2)
go build -o builds/protoplex_${GOOS}_${GOARCH} -ldflags "-s -w" ./cmd/protoplex
'''
pipeline {
agent {
label 'go'
}
stages {
stage('Prepare') {
steps{
checkout scm
sh 'go get -u -v .'
sh 'mkdir -p builds'
}
}
stage('Build') {
stages {
stage('linux/386') {
steps {
sh buildCommand
}
}
stage('linux/amd64') {
steps {
sh buildCommand
}
}
stage('linux/arm') {
steps {
sh buildCommand
}
}
stage('linux/arm64') {
steps {
sh buildCommand
}
}
stage('linux/mips') {
steps {
sh buildCommand
}
}
stage('linux/mips64') {
steps {
sh buildCommand
}
}
stage('linux/mips64le') {
steps {
sh buildCommand
}
}
stage('linux/ppc64') {
steps {
sh buildCommand
}
}
stage('linux/ppc64le') {
steps {
sh buildCommand
}
}
stage('linux/s390x') {
steps {
sh buildCommand
}
}
stage('windows/386') {
steps {
sh buildCommand
}
}
stage('windows/amd64') {
steps {
sh buildCommand
}
}
stage('windows/arm') {
steps {
sh buildCommand
}
}
stage('freebsd/386') {
steps {
sh buildCommand
}
}
stage('freebsd/amd64') {
steps {
sh buildCommand
}
}
stage('freebsd/arm') {
steps {
sh buildCommand
}
}
stage('netbsd/386') {
steps {
sh buildCommand
}
}
stage('netbsd/amd64') {
steps {
sh buildCommand
}
}
stage('netbsd/arm') {
steps {
sh buildCommand
}
}
}
}
stage('Cleanup') {
steps {
archiveArtifacts 'builds/*'
}
}
}
}

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module github.com/Pandentia/protoplex
go 1.12
require github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI=
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=