Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (43 sloc) 1.35 KB
def bucket = 'deployment-packages-mlabouardy'
def functionName = 'Fibonacci'
def region = 'eu-west-3'
node('slaves'){
stage('Checkout'){
checkout scm
}
stage('Test'){
sh 'go get -u github.com/golang/lint/golint'
sh 'go get -t ./...'
//sh 'golint -set_exit_status'
sh 'go vet .'
sh 'go test .'
}
stage('Build'){
sh 'GOOS=linux go build -o main main.go'
sh "zip ${commitID()}.zip main"
}
stage('Push'){
sh "aws s3 cp ${commitID()}.zip s3://${bucket}"
}
stage('Deploy'){
sh "aws lambda update-function-code --function-name ${functionName} \
--s3-bucket ${bucket} \
--s3-key ${commitID()}.zip \
--region ${region}"
}
if (env.BRANCH_NAME == 'master') {
stage('Publish') {
def lambdaVersion = sh(
script: "aws lambda publish-version --function-name ${functionName} --region ${region} | jq -r '.Version'",
returnStdout: true
)
sh "aws lambda update-alias --function-name ${functionName} --name production --region ${region} --function-version ${lambdaVersion}"
}
}
}
def commitID() {
sh 'git rev-parse HEAD > .git/commitID'
def commitID = readFile('.git/commitID').trim()
sh 'rm .git/commitID'
commitID
}
You can’t perform that action at this time.