summaryrefslogtreecommitdiff
path: root/Jenkinsfile
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-11-10 22:21:29 +0100
committerChristian Poessinger <christian@poessinger.com>2019-11-10 22:21:29 +0100
commit468dc26d5b94cfa88ab0c91321d6493c8209c20f (patch)
tree04a71d722f9d27ab2c559432bba73921811a5f00 /Jenkinsfile
parent23c3ee3a9c2eac08c2a2e0f9556238f6bf7d6afd (diff)
downloadvyos-build-468dc26d5b94cfa88ab0c91321d6493c8209c20f.tar.gz
vyos-build-468dc26d5b94cfa88ab0c91321d6493c8209c20f.zip
Jenkins: import Pipeline from current branch
Diffstat (limited to 'Jenkinsfile')
-rw-r--r--Jenkinsfile112
1 files changed, 75 insertions, 37 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index 4bc64b26..2abfa282 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,70 +1,108 @@
#!/usr/bin/env groovy
+// Copyright (C) 2019 VyOS maintainers and contributors
+//
+// This program is free software; you can redistribute it and/or modify
+// in order to easy exprort images built to "external" world
+// it under the terms of the GNU General Public License version 2 or later as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
@NonCPS
+
+def getGitBranchName() {
+ def branch = scm.branches[0].name
+ return branch.split('/')[-1]
+}
+
+def getGitRepoURL() {
+ return scm.userRemoteConfigs[0].url
+}
+
+def getGitRepoName() {
+ return getGitRepoURL().split('/').last()
+}
+
+// Returns true if this is a custom build launched on any project fork.
+// Returns false if this is build from git@github.com:vyos/<reponame>.
+// <reponame> can be e.g. vyos-1x.git or vyatta-op.git
+def isCustomBuild() {
+ // GitHub organisation base URL
+ def gitURI = 'git@github.com:vyos/' + getGitRepoName()
+ def httpURI = 'https://github.com/vyos/' + getGitRepoName()
+
+ return ! ((getGitRepoURL() == gitURI) || (getGitRepoURL() == httpURI))
+}
+
def setDescription() {
def item = Jenkins.instance.getItemByFullName(env.JOB_NAME)
- item.setDescription("VyOS image build using a\nPipeline build inside Docker container.")
+
+ // build up the main description text
+ def description = ""
+ description += "<h2>Build VyOS ISO image</h2>"
+
+ if (isCustomBuild()) {
+ description += "<p style='border: 3px dashed red; width: 50%;'>"
+ description += "<b>Build not started from official Git repository!</b><br>"
+ description += "<br>"
+ description += "Repository: <font face = 'courier'>" + getGitRepoURL() + "</font><br>"
+ description += "Branch: <font face = 'courier'>" + getGitBranchName() + "</font><br>"
+ description += "</p>"
+ } else {
+ description += "Sources taken from Git branch: <font face = 'courier'>" + getGitBranchName() + "</font><br>"
+ }
+
+ item.setDescription(description)
item.save()
}
-setDescription()
-
/* Only keep the 10 most recent builds. */
def projectProperties = [
- [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],
+ [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '1']],
]
properties(projectProperties)
+setDescription()
pipeline {
+ options {
+ disableConcurrentBuilds()
+ timeout(time: 90, unit: 'MINUTES')
+ parallelsAlwaysFailFast()
+ }
+ triggers {
+ cron('H 2 * * *')
+ }
agent {
dockerfile {
filename 'Dockerfile'
- label 'jessie-amd64'
dir 'docker'
args '--privileged --sysctl net.ipv6.conf.lo.disable_ipv6=0 -e GOSU_UID=1006 -e GOSU_GID=1006'
}
}
-
stages {
- stage('Submodule Init') {
- steps {
- sh '''
- git submodule update --init --recursive --remote
- '''
- }
- }
- stage('Build Packages') {
+ stage('Configure') {
steps {
- sh '''
- #!/bin/sh
- scripts/build-submodules --verbose
- '''
+ script {
+ def commitId = sh(returnStdout: true, script: 'git rev-parse --short=11 HEAD').trim()
+ currentBuild.description = sprintf('Git SHA1: %s', commitId[-11..-1])
+
+ sh './configure --build-by autobuild@vyos.net --debian-mirror http://ftp.us.debian.org/debian/'
+ }
}
}
-
- stage('Build ISO') {
+ stage('Build') {
steps {
- sh '''
- #!/bin/sh
-
- # we do not want to fetch VyOS packages from the mirror,
- # we rather prefer all build by ourself!
- sed -i '/vyos_repo_entry/d' scripts/live-build-config
-
- # Configure the ISO
- ./configure --build-by="autobuild@vyos.net" --debian-mirror="http://ftp.us.debian.org/debian/"
-
- # Debug to see which Debian packages we have so far
- ls -al packages/*.deb
-
- # Finally build our ISO
- sudo make iso
- '''
+ sh 'sudo make iso'
}
}
}
-
post {
cleanup {
echo 'One way or another, I have finished'