Skip to content

Instantly share code, notes, and snippets.

@abtris
Last active July 17, 2019 04:34
Show Gist options
  • Save abtris/e3e403d9b8cea31c66ccb67ae4c7f3f5 to your computer and use it in GitHub Desktop.
Save abtris/e3e403d9b8cea31c66ccb67ae4c7f3f5 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