Skip to content

Commit

Permalink
WIP - Migrate release scripts - Initial commit (#32)
Browse files Browse the repository at this point in the history
* Migrate release scripts

Signed-off-by: Matthew Conger-Eldeen <[email protected]>
Signed-off-by: Helen Shao <[email protected]>
  • Loading branch information
akodali18 authored May 3, 2022
1 parent 06e38bc commit 96056c3
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM busybox:1.29.2-glibc
FROM harbor-repo.vmware.com/dockerhub-proxy-cache/library/busybox:1.29.2-glibc

COPY target/adapter_linux /bin/adapter

USER nobody
ENTRYPOINT [ "/bin/adapter" ]
ENTRYPOINT [ "/bin/adapter" ]
86 changes: 86 additions & 0 deletions release.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pipeline {

agent any

tools {
go 'Go 1.18'
}

environment {
RELEASE_TYPE = 'release'
GIT_CREDENTIAL_ID = 'wf-jenkins-github'
GITHUB_TOKEN = credentials('GITHUB_TOKEN')
REPO_NAME = 'prometheus-storage-adapter'
}

parameters {
string(name: 'VERSION_NUMBER', defaultValue: '', description: 'The version number to release as')
string(name: 'TARGET_COMITISH', defaultValue: 'master', description: 'Specify a specific commit hash or branch to release the version to.')
string(name: 'RELEASE_NOTES', defaultValue: '', description: 'The public release notes for the version. Use \\n to create newlines')
booleanParam(name: 'IS_DRAFT', defaultValue: false, description: 'If the release should be marked as a draft (unpublished)')
booleanParam(name: 'IS_PRERELEASE', defaultValue: false, description: 'If the release should be marked as a prerelease')
booleanParam(name: 'createGithubRelease', defaultValue: true, description: 'Mark as false if you only want to build/push docker images. Note: a tag specified by the name VERSION_NUMBER must be created in the repo already for this option to be turned off')
}

stages {
stage('Build Linux Binary') {
steps {
script {
sh "make build-linux"
}
}
}

stage('Create Github Release') {
steps {
script {
if (params.createGithubRelease) {
TARGET_COMITISH_TRIMMED = TARGET_COMITISH.minus("origin/")
sh "curl -XPOST -H \"Authorization: token ${GITHUB_TOKEN}\" -H \"Accept: application/vnd.github.v3+json\" https://api.github.com/repos/wavefrontHQ/${REPO_NAME}/releases -d \'{\"tag_name\": \"${VERSION_NUMBER}\", \"target_commitish\": \"${TARGET_COMITISH_TRIMMED}\", \"body\": \"${RELEASE_NOTES}\", \"draft\": ${IS_DRAFT}, \"prerelease\": ${IS_PRERELEASE}}\'"
}
}
}
}

stage('Make/Push Docker Image') {
steps {
script {
docker.withRegistry('https://projects.registry.vmware.com', 'projects-registry-vmware-tanzu_observability-robot') {
def harborImage = docker.build("tanzu_observability/${REPO_NAME}:${VERSION_NUMBER}")
/* Push the container to the custom Registry */
harborImage.push()
harborImage.push("latest")
}

docker.withRegistry('https://index.docker.io/v1/', 'Dockerhub_svcwfjenkins') {
def dockerHubImage = docker.build("wavefronthq/${REPO_NAME}:${VERSION_NUMBER}")
dockerHubImage.push()
dockerHubImage.push("latest")
}
}
}
}
}

post {
// Notify only on null->failure or success->failure or any->success
failure {
script {
if(currentBuild.previousBuild == null) {
slackSend (channel: '#tobs-k8po-team', color: '#FF0000', message: "RELEASE BUILD FAILED: <${env.BUILD_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>")
}
}
}
regression {
slackSend (channel: '#tobs-k8po-team', color: '#FF0000', message: "RELEASE BUILD FAILED: <${env.BUILD_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>")
}
success {
script {
slackSend (channel: '#tobs-k8s-assist', color: '#008000', message: "Success!! `prometheus-storage-adapter:${VERSION_NUMBER}` released!")
}
}
always {
cleanWs()
}
}
}

0 comments on commit 96056c3

Please sign in to comment.