Skip to content

Commit

Permalink
Add Jenkinsfile for multibranch pipeline jenkins job (#280)
Browse files Browse the repository at this point in the history
* Add initial Jenkinsfile

* Add environment variables from credentials

* Fix syntax issue

* Fix matrix and go tool issues

* Remove debugging steps

* Test matrix with additional tf version

* Add lock to prevent multiple concurrent builds

* Add required resource parameter

* Try without keyword arguments

* Ensure TF_ACC_TERRAFORM_VERSION is set
  • Loading branch information
ddelnano authored Dec 3, 2023
1 parent 791214e commit 6f9d08e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
43 changes: 43 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline {
agent any
environment {
XOA_URL = credentials("terraform-provider-xoa-url")
XOA_USER = credentials("terraform-provider-xoa-user")
XOA_PASSWORD = credentials("terraform-provider-xoa-password")
XOA_POOL = credentials("terraform-provider-xoa-pool")
XOA_TEMPLATE = credentials("terraform-provider-xoa-template")
XOA_DISKLESS_TEMPLATE = credentials("terraform-provider-xoa-diskless-template")
XOA_ISO = credentials("terraform-provider-xoa-iso")
XOA_ISO_SR = credentials("terraform-provider-xoa-iso-sr")
XOA_NETWORK = credentials("terraform-provider-xoa-network")
XOA_RETRY_MAX_TIME = credentials("terraform-provider-xoa-retry-max-time")
XOA_RETRY_MODE = credentials("terraform-provider-xoa-retry-mode")
}

// Ensure the desired Go version is installed for all stages,
// using the name defined in the Global Tool Configuration
tools { go '1.20' }

stages {
stage('BuildAndTest') {
matrix {
axes {
axis {
name 'TF_VERSION'
values 'v0.14.11', 'v1.6.5'
}
}
stages {
stage('Test') {
steps {
lock('xoa-test-runner') {
sh 'cp /opt/terraform-provider-xenorchestra/testdata/images/alpine-virt-3.17.0-x86_64.iso xoa/testdata/alpine-virt-3.17.0-x86_64.iso'
sh 'TF_VERSION=${TF_VERSION} make ci'
}
}
}
}
}
}
}
}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

TIMEOUT ?= 40m
GOMAXPROCS ?= 5
TF_VERSION ?= v0.14.11
ifdef TEST
TEST := github.com/ddelnano/terraform-provider-xenorchestra/xoa -run '$(TEST)'
else
Expand Down Expand Up @@ -44,4 +45,4 @@ testacc: xoa/testdata/alpine-virt-3.17.0-x86_64.iso
# to be removed from the repo. Add a target to enforce that the CI system
# has copied that file into place before the tests run
ci: xoa/testdata/alpine-virt-3.17.0-x86_64.iso
TF_ACC=1 gotestsum --debug --rerun-fails=5 --max-fails=15 --packages=./xoa -- ./xoa -v -count=1 -timeout=$(TIMEOUT) -sweep=true -parallel=$(GOMAXPROCS)
TF_ACC_TERRAFORM_VERSION=$(TF_VERSION) TF_ACC=1 gotestsum --debug --rerun-fails=5 --max-fails=15 --packages=./xoa -- ./xoa -v -count=1 -timeout=$(TIMEOUT) -sweep=true -parallel=$(GOMAXPROCS)

0 comments on commit 6f9d08e

Please sign in to comment.