Skip to content

Instantly share code, notes, and snippets.

@tmpbook
Created July 25, 2018 03:42
Show Gist options
  • Save tmpbook/2907088597892497b98874acc134156d to your computer and use it in GitHub Desktop.
Save tmpbook/2907088597892497b98874acc134156d to your computer and use it in GitHub Desktop.
Jenkins build setup for Go Projects.
# You need install jenkins go plugin first -> https://wiki.jenkins.io/display/JENKINS/Go+Plugin
#!/usr/bin/bash
export GOPATH=$WORKSPACE
mkdir -p $GOPATH/src
project_name=$(echo $GIT_URL | awk -F/ '{print $NF}' | sed 's/.git//g')
echo ${project_name}
ln -f -s $WORKSPACE $GOPATH/src/$project_name
go get $project_name
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o $project_name $project_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment