diff --git a/Dockerfile b/Dockerfile index f67e23a..b0b1766 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] \ No newline at end of file +ENTRYPOINT [ "/bin/adapter" ] diff --git a/release.Jenkinsfile b/release.Jenkinsfile new file mode 100644 index 0000000..db5ff78 --- /dev/null +++ b/release.Jenkinsfile @@ -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() + } + } +}