From 8f1c11feb9d1cf4e41f9f0f22098ead43abd381e Mon Sep 17 00:00:00 2001 From: Milan Rafaj <10629777+eufebius@users.noreply.github.com> Date: Mon, 15 May 2023 11:54:50 +0200 Subject: [PATCH] add china rsync jenkinsfile --- build/Jenkinsfile | 42 ++++++++++++++++++++ build/job_def/deploy_pflib_china.job | 59 ++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 build/Jenkinsfile create mode 100644 build/job_def/deploy_pflib_china.job diff --git a/build/Jenkinsfile b/build/Jenkinsfile new file mode 100644 index 0000000..aa9dfe9 --- /dev/null +++ b/build/Jenkinsfile @@ -0,0 +1,42 @@ +#!/usr/bin/env groovy + +@Library("pfJenkinsLibrary@0.27.3") _ + +String projectName = 'pf-podtemplate-library' +String podTemplateName = projectName +String pfRepo = "git@github.com:pixelfederation/${projectName}.git" +String pfChinaRepo = "devops/${projectName}.git" +String cnGitServer = "git@gogs.prod.cn-northwest-1.k8s.pxfd.tech" + +podTemplateConf = [ name: "${podTemplateName}", label: "${podTemplateName}", inheritFrom: 'default-jnlp-util'] + +echo "podTemplateConf is : ${podTemplateConf}" + +podTemplate( podTemplateConf ) { + node( podTemplateConf.name ) { + try { + ansiColor('xterm') { + stage('Clone Repositories and sync') { + container('util') { + sh """ + git clone ${cnGitServer}:${pfChinaRepo} china + git clone ${pfRepo} upstream + cd china + for tag in \$(git tag --sort=creatordate| tail -n 10| awk '{ print \$1}') + do + git push --delete origin \$tag & + done + for job in \$(jobs -p);do wait \$job;done + cd ../upstream + git remote set-url origin ${cnGitServer}:${pfChinaRepo} + git push --all --force + git push --tags --force + """ + } + } + } + } catch(e) { + throw e + } + } +} diff --git a/build/job_def/deploy_pflib_china.job b/build/job_def/deploy_pflib_china.job new file mode 100644 index 0000000..457ac58 --- /dev/null +++ b/build/job_def/deploy_pflib_china.job @@ -0,0 +1,59 @@ +pipelineJob("deploy-pfpodtemplatelib-china") { + description() + keepDependencies(false) + properties { + disableConcurrentBuilds() + pipelineTriggers{ + triggers { + genericTrigger { + genericVariables { + genericVariable { + key("ref") + value("\$.ref") + } + genericVariable { + key("pusher") + value("\$.pusher.name") + } + } + token('aqmQO0oQQIu96nP50daTP1krj7MbEC8d') + causeString("Started by GitHub push by \$pusher") + regexpFilterText("\$ref") + regexpFilterExpression("^(refs/tags/.+)") + } + } + } + } + configure { + it / 'properties' / 'com.coravy.hudson.plugins.github.GithubProjectProperty' { + 'projectUrl'('https://github.com/pixelfederation/pf-podtemplate-library.git/') + displayName() + } + } + definition { + cpsScm { + scm { + git { + remote { + url("https://github.com/pixelfederation/pf-podtemplate-library.git") + credentials("jenkins-github-token") + } + branch("master") + } + } + scriptPath("build/Jenkinsfile") + lightweight(true) + } + } + disabled(false) + configure { + it / 'properties' / 'jenkins.model.BuildDiscarderProperty' { + strategy { + 'daysToKeep'('-1') + 'numToKeep'('25') + 'artifactDaysToKeep'('-1') + 'artifactNumToKeep'('-1') + } + } + } +}