Skip to content

Instantly share code, notes, and snippets.

@josefsalyer
Forked from abtris/02-Jenkinsfile
Created July 13, 2017 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josefsalyer/b848dc5b4833f2dfd62f304191fa46dd to your computer and use it in GitHub Desktop.
Save josefsalyer/b848dc5b4833f2dfd62f304191fa46dd to your computer and use it in GitHub Desktop.
Jenkinsfile - imperative style vs declarative style
pipeline {
agent any
environment {
PACKAGE="github.com/abtris/bee"
GOPATH="/Users/abtris/go"
GOROOT="/usr/local/opt/go/libexec"
}
stages {
stage('Preparation') {
steps {
git 'https://github.com/abtris/bee.git'
}
}
stage('Deps') {
steps {
sh 'glide --no-color install'
sh 'mkdir -p release'
}
}
stage('Test') {
steps {
sh 'make xunit'
}
}
stage('Build') {
steps {
parallel (
linux64: { sh "GOOS=linux GOARCH=amd64 go build -o release/bee-linux-amd64 ${PACKAGE}" },
linux32: { sh "GOOS=linux GOARCH=386 go build -o release/bee-linux-386 ${PACKAGE}" },
mac64: { sh "GOOS=darwin GOARCH=amd64 go build -o release/bee-darwin-amd64 ${PACKAGE}" },
win64: { sh "GOOS=windows GOARCH=amd64 go build -o release/bee-windows-amd64 ${PACKAGE}" }
)
}
}
stage('Results') {
steps {
archive 'release/*'
junit 'tests.xml'
}
}
}
}
node {
stage('Preparation') {
git 'https://github.com/abtris/bee.git'
poll: true
}
stage('Deps') {
env.PACKAGE="github.com/abtris/bee"
env.GOPATH="/Users/abtris/go"
env.GOROOT="/usr/local/opt/go/libexec"
sh 'glide --no-color install'
sh 'mkdir -p release'
}
stage('Test') {
sh 'make xunit'
}
stage('Build') {
parallel (
linux64: { sh "GOOS=linux GOARCH=amd64 go build -o release/bee-linux-amd64 ${PACKAGE}" },
linux32: { sh "GOOS=linux GOARCH=386 go build -o release/bee-linux-386 ${PACKAGE}" },
mac64: { sh "GOOS=darwin GOARCH=amd64 go build -o release/bee-darwin-amd64 ${PACKAGE}" },
win64: { sh "GOOS=windows GOARCH=amd64 go build -o release/bee-windows-amd64 ${PACKAGE}" }
)
}
stage('Results') {
archive 'release/*'
junit 'tests.xml'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment