Created
May 22, 2016 17:23
-
-
Save mweagle/4822c3210d681a06409f9b55ab1626ed to your computer and use it in GitHub Desktop.
Jenkins 2.0 build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def golangExists = fileExists '/home/ec2-user/go' | |
if (!golangExists) { | |
stage "Configure Go" | |
sh('curl -vs -L https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz -o /home/ec2-user/go.linux-amd64.tar.gz') | |
sh('tar -xzf /home/ec2-user/go.linux-amd64.tar.gz -C /home/ec2-user') | |
} else { | |
sh('echo Go installed') | |
} | |
withEnv(['GOROOT=/home/ec2-user/go', 'GOPATH=$PWD', 'GOBIN=$PWD/bin','AWS_REGION=us-west-2']) { | |
stage 'Checkout' | |
checkout([$class: 'GitSCM', | |
branches: [[name: '*/master']], | |
doGenerateSubmoduleConfigurations: false, | |
extensions: [[$class: 'CleanBeforeCheckout'], | |
[$class: 'CleanCheckout'], | |
[$class: 'WipeWorkspace'], | |
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'src/SpartaHelloWorld/']], | |
submoduleCfg: [], | |
userRemoteConfigs: [[url: 'https://github.com/mweagle/SpartaHelloWorld']]]) | |
sh 'echo --------------------------' | |
sh 'mkdir -pv $PWD/{src,pkg,bin}' | |
withEnv(['PATH=$PATH:$GOROOT/bin']) { | |
// Go get https://github.com/tebeka/go2xunit to massage test results | |
sh('go get -v bitbucket.org/tebeka/go2xunit') | |
dir('src/SpartaHelloWorld') { | |
def vendorExists = fileExists '.vendor' | |
if (vendorExists) { | |
sh 'echo ./vendor directory found' | |
} else { | |
sh 'echo ./vendor directory not found' | |
stage 'Resolve Dependencies' | |
sh 'go get -v ./...' | |
} | |
stage 'Unit Test' | |
sh 'go test -v | go2xunit -fail -output go-test.xml' | |
step([$class: 'JUnitResultArchiver', testResults: 'go-test.xml', allowEmptyResults:true]) | |
stage 'Build' | |
sh 'go build -o sparta.lambda.amd64' | |
stage 'Provision' | |
sh 'echo ./sparta.lambda.amd64 --level info provision --s3Bucket weagle' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment