summaryrefslogtreecommitdiff
path: root/vars/buildPackage.groovy
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-06-20 22:45:22 +0200
committerChristian Poessinger <christian@poessinger.com>2020-06-20 23:11:56 +0200
commit22888ab75116af69fe88ec79e95ba8c5559f1e5b (patch)
treed83851452df798c47df505e10c3253a5bf2eaa4a /vars/buildPackage.groovy
parentb213775285018e0610bc307abc08bd5db956a8c9 (diff)
downloadvyos-build-22888ab75116af69fe88ec79e95ba8c5559f1e5b.tar.gz
vyos-build-22888ab75116af69fe88ec79e95ba8c5559f1e5b.zip
Jenkins: lib: deploy packages do dev.packages.vyos.net
Diffstat (limited to 'vars/buildPackage.groovy')
-rw-r--r--vars/buildPackage.groovy42
1 files changed, 42 insertions, 0 deletions
diff --git a/vars/buildPackage.groovy b/vars/buildPackage.groovy
index 96d6a164..f2a72dc4 100644
--- a/vars/buildPackage.groovy
+++ b/vars/buildPackage.groovy
@@ -54,6 +54,7 @@ def call(description, pkgList) {
// get relative directory path to Jenkinsfile
BASE_DIR = currentBuild.rawBuild.parent.definition.scriptPath.replace('Jenkinsfile', '')
CHANGESET_DIR = "**/${env.BASE_DIR}*"
+ DEBIAN_ARCH = sh(returnStdout: true, script: 'dpkg --print-architecture').trim()
}
options {
disableConcurrentBuilds()
@@ -116,6 +117,47 @@ def call(description, pkgList) {
if (isCustomBuild()) {
// archive *.deb artifact on custom builds, deploy to repo otherwise
archiveArtifacts artifacts: '**/*.deb', allowEmptyArchive: true
+ } else {
+ // publish build result, using SSH-dev.packages.vyos.net Jenkins Credentials
+ sshagent(['SSH-dev.packages.vyos.net']) {
+ // build up some fancy groovy variables so we do not need to write/copy
+ // every option over and over again!
+ def RELEASE = getGitBranchName()
+ if (getGitBranchName() == "master") {
+ RELEASE = 'current'
+ }
+
+ def VYOS_REPO_PATH = '/home/sentrium/web/dev.packages.vyos.net/public_html/repositories/' + RELEASE + '/'
+ if (getGitBranchName() == "crux")
+ VYOS_REPO_PATH += 'vyos/'
+
+ def SSH_OPTS = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR'
+ def SSH_REMOTE = 'khagen@10.217.48.113'
+
+ echo "Uploading package(s) and updating package(s) in the repository ..."
+
+ def SSH_DIR = '~/VyOS/' + RELEASE + '/' + env.DEBIAN_ARCH
+ def ARCH_OPT = ''
+ if (env.DEBIAN_ARCH != 'all')
+ ARCH_OPT = '-A ' + env.DEBIAN_ARCH
+
+ sh """scp ${SSH_OPTS} *.deb ${SSH_REMOTE}:${SSH_DIR}/"""
+
+ files = findFiles(glob: '*.deb')
+ files.each { FILE ->
+ def PKG = sh(returnStdout: true, script: "dpkg-deb -f ${FILE} Package").trim()
+ // No need to explicitly check the return code. The pipeline
+ // will fail if sh returns a noni-zero exit code
+ sh """
+ ssh ${SSH_OPTS} ${SSH_REMOTE} "mkdir -p ${SSH_DIR}"
+ ssh ${SSH_OPTS} ${SSH_REMOTE} "\
+ uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} ${ARCH_OPT} remove ${RELEASE} ${PKG}'; \
+ uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} deleteunreferenced'; \
+ uncron-add 'reprepro -v -b ${VYOS_REPO_PATH} ${ARCH_OPT} includedeb ${RELEASE} ${SSH_DIR}/${FILE}'; \
+ "
+ """
+ }
+ }
}
}
}