From a9011b95b91c130589fa2a354e4b463f5121dbed Mon Sep 17 00:00:00 2001 From: gkirok Date: Mon, 13 Jul 2020 16:32:38 +0300 Subject: [PATCH] Add gcr (#22) * gcr --- Jenkinsfile | 73 ++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 51 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bb3ab48..f170d3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,65 +1,36 @@ label = "${UUID.randomUUID().toString()}" -expired=240 git_project = "nuclio-templates" git_project_user = "nuclio" +git_project_upstream_user = "nuclio" +git_deploy_user = "iguazio-prod-git-user" git_deploy_user_token = "iguazio-prod-git-user-token" git_deploy_user_private_key = "iguazio-prod-git-user-private-key" podTemplate(label: "${git_project}-${label}", inheritFrom: "jnlp-docker") { node("${git_project}-${label}") { - withCredentials([ - string(credentialsId: git_deploy_user_token, variable: 'GIT_TOKEN') - ]) { - def TAG_VERSION - pipelinex = library(identifier: 'pipelinex@DEVOPS-204-pipelinex', retriever: modernSCM( - [$class: 'GitSCMSource', - credentialsId: git_deploy_user_private_key, - remote: "git@github.com:iguazio/pipelinex.git"])).com.iguazio.pipelinex - - common.notify_slack { - stage('get tag data') { - container('jnlp') { - TAG_VERSION = github.get_tag_version(TAG_NAME) - PUBLISHED_BEFORE = github.get_tag_published_before(git_project, git_project_user, "${TAG_VERSION}", GIT_TOKEN) - - echo "$TAG_VERSION" - echo "$PUBLISHED_BEFORE" - } - } - - if (TAG_VERSION != null && TAG_VERSION.length() > 0 && PUBLISHED_BEFORE < expired) { - parallel( - 'source archive': { - container('jnlp') { - sh("wget https://github.com/${git_project_user}/${git_project}/archive/${TAG_VERSION}.zip") + pipelinex = library(identifier: 'pipelinex@development', retriever: modernSCM( + [$class : 'GitSCMSource', + credentialsId: git_deploy_user_private_key, + remote : "git@github.com:iguazio/pipelinex.git"])).com.iguazio.pipelinex + common.notify_slack { + withCredentials([ + string(credentialsId: git_deploy_user_token, variable: 'GIT_TOKEN') + ]) { + github.release(git_deploy_user, git_project, git_project_user, git_project_upstream_user, true, GIT_TOKEN) { + stage("upload ${git_project} zip to artifactory") { + container('jnlp') { + sh("wget https://github.com/${git_project_user}/${git_project}/archive/${github.TAG_VERSION}.zip") - zip_path = sh( - script: "pwd", - returnStdout: true - ).trim() + zip_path = sh( + script: "pwd", + returnStdout: true + ).trim() - withCredentials([ - string(credentialsId: pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[2], variable: 'PACKAGES_ARTIFACTORY_PASSWORD') - ]) { - common.upload_file_to_artifactory(pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[0], pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[1], PACKAGES_ARTIFACTORY_PASSWORD, "iguazio-devops/nuclio-templates", "${TAG_VERSION}.zip", zip_path) - } - } + withCredentials([ + string(credentialsId: pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[2], variable: 'PACKAGES_ARTIFACTORY_PASSWORD') + ]) { + common.upload_file_to_artifactory(pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[0], pipelinex.PackagesRepo.ARTIFACTORY_IGUAZIO[1], PACKAGES_ARTIFACTORY_PASSWORD, "iguazio-devops/nuclio-templates", "${github.TAG_VERSION}.zip", zip_path) } - ) - - stage('update release status') { - container('jnlp') { - github.update_release_status(git_project, git_project_user, "${TAG_VERSION}", GIT_TOKEN) - } - } - } else { - stage('warning') { - if (PUBLISHED_BEFORE >= expired) { - currentBuild.result = 'ABORTED' - error("Tag too old, published before $PUBLISHED_BEFORE minutes.") - } else { - currentBuild.result = 'ABORTED' - error("${TAG_VERSION} is not release tag.") } } }