ci: Begin Jenkins build pipeline
dustin/dynk8s-provisioner/pipeline/head There was a failure building this commit Details

Dustin 2022-09-05 22:41:47 -05:00
parent ac1b20d910
commit 16d941be6a
10 changed files with 118 additions and 0 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
target/
!target/*/dynk8s-provisioner
src/
test/

View File

@ -8,3 +8,8 @@ trim_trailing_whitespace = true
[**.rs]
max_line_length = 79
[Jenkinsfile]
max_line_length = 79
indent_style = space
indent_size = 4

5
Containerfile Normal file
View File

@ -0,0 +1,5 @@
FROM fedora:36
COPY target/release/dynk8s-provisioner /usr/bin/
CMD ["/usr/bin/dynk8s-provisioner"]

59
ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,59 @@
pipeline {
agent {
kubernetes {
yamlFile 'ci/podTemplate.yaml'
workspaceVolume dynamicPVC()
}
}
options {
buildDiscarder logRotator(numToKeepStr: '5')
disableConcurrentBuilds()
}
environment {
CARGO_HOME = "${env.WORKSPACE}/.cargo"
TMPDIR = "${env.WORKSPACE_TMP}"
}
stages {
stage('Test') {
steps {
container('build') {
sh '. ci/test.sh'
}
}
}
stage('Build') {
steps {
container('build') {
sh '. ci/build.sh'
}
}
post {
success {
dir('target/release') {
archiveArtifacts 'dynk8s-provisioner'
}
}
}
}
stage('Container') {
steps {
container('podman') {
sh '. ci/container.sh'
}
}
}
stage('Publish') {
steps {
container('podman') {
sh '. ci/publish.sh'
}
}
}
}
}

3
ci/build.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash -ex
cargo build --release

5
ci/common.sh Normal file
View File

@ -0,0 +1,5 @@
# shellcheck: shell=sh
tag_name() {
echo "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g' -e 's/^[.-]/_/'
}

5
ci/container.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash -ex
. ci/common.sh
podman build -t dynk8s-provider:$(tag_name ${BUILD_TAG}) .

19
ci/podTemplate.yaml Normal file
View File

@ -0,0 +1,19 @@
spec:
securityContext:
fsGroup: 1000
containers:
- name: build
image: docker.io/rust:1.63
command:
- sleep
- infinity
securityContext:
readOnlyRootFilesystem: true
runAsUser: 1000
- name: podman
image: quay.io/containers/podman:v3.4
command:
- sleep
- infinity
securityContext:
privileged: true

10
ci/publish.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash -ex
. ci/common.sh
remote=gitea.pyrocufflink.blue/dustin/dynk8s-provisioner
t=$(tag_name ${BUILD_TAG})
podman push -t dynk8s-provider:${t} ${remote}:${t}
if [ "${BRANCH_NAME}" = master ]; then
podman push -t dynk8s-provider:${t} ${remote}:${t}
fi

3
ci/test.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash -ex
cargo test