Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated build #228

Merged
merged 7 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pipeline {
agent {
kubernetes {
label 'package-linux'
yamlFile 'KubernetesPod.yaml'
workingDir '/home/jenkins/agent'
}
}

options {
disableConcurrentBuilds(abortPrevious: true)
buildDiscarder logRotator(numToKeepStr: '5') // Retain only last 5 builds to reduce space requirements
}

environment {
JENKINS_VERSION = 'latest'
JENKINS_DOWNLOAD_URL= 'https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/'
WAR = "${WORKSPACE}/target/war/jenkins.war"
MSI = "${WORKSPACE}/target/msi/jenkins.msi"
BRAND = "${WORKSPACE}/branding/common"
ORGANIZATION = 'example.org'
BUILDENV = "${WORKSPACE}/env/test.mk"
CREDENTIAL = "${WORKSPACE}/credentials/test.mk"
GPG_KEYNAME = 'test'
GPG_KEYRING = "${WORKSPACE}/credentials/${GPG_KEYNAME}.gpg"
GPG_SECRET_KEYRING = "${WORKSPACE}/credentials/${GPG_KEYNAME}.secret.gpg"
}

stages {
stage('Prep') {
steps {
checkout scm
sh './prep.sh'
}
}
stage('Build') {
steps {
sh 'make war deb rpm suse'
}
post {
success {
archiveArtifacts 'target/war/*.war, target/debian/*.deb, target/rpm/*.rpm, target/suse/*.rpm'
}
}
}
}
}
25 changes: 25 additions & 0 deletions KubernetesPod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
jenkins: "agent"
job: "package"
spec:
containers:
- name: jnlp
image: jenkinsciinfra/packaging:latest
env:
- name: "HOME"
value: "/home/jenkins/agent/workspace"
resources:
limits:
memory: "1Gi"
cpu: "1"
requests:
memory: "1Gi"
cpu: "1"
securityContext:
privileged: false
runAsUser: 1000
runAsGroup: 1000
21 changes: 21 additions & 0 deletions prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -eux
set -o pipefail
cd "$(dirname "$0")"

# TODO jenkins-infra/release performs similar preparatory actions: downloading
# the WAR and importing the GPG key. A common interface for the preparatory
# actions should be designed that meets the needs of both local testing and
# releases, ideally implemented in the Makefile. Then both this repository and
# jenkins-infra/release should be refactored to consume the new functionality.

if [[ ! -f $WAR ]]; then
mkdir -p "$(dirname "${WAR}")"
jv download
fi

if ! gpg --fingerprint "${GPG_KEYNAME}"; then
gpg --import --batch "${GPG_KEYRING}" "${GPG_SECRET_KEYRING}"
fi

# produces: target/war/jenkins.war
exit 0