You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.3 KiB
93 lines
2.3 KiB
pipeline {
|
|
environment {
|
|
BUILD_IMAGE = 'gobuild:1.19'
|
|
BUILD_ARGS = '-e HOME=${WORKSPACE} -v /var/lib/jenkins/go/pkg:/go/pkg'
|
|
PATH = '/go/bin:~/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin'
|
|
composeFile = "deployments/docker-compose-integration.yaml"
|
|
networkName = "network-${env.BUILD_TAG}"
|
|
registryCredential = 'docker-io-feditools'
|
|
scannerHome = tool 'SonarScanner 4.0'
|
|
}
|
|
|
|
agent any
|
|
|
|
stages {
|
|
|
|
stage('Start External Test Requirements'){
|
|
steps{
|
|
script{
|
|
retry(2) {
|
|
sh """NETWORK_NAME="${networkName}" docker-compose -f ${composeFile} pull
|
|
NETWORK_NAME="${networkName}" docker-compose -p ${env.BUILD_TAG} -f ${composeFile} up -d"""
|
|
}
|
|
parallel(
|
|
postgres: {
|
|
retry(30) {
|
|
sleep 1
|
|
sh "docker run -t --rm --network=${networkName} subfuzion/netcat -z postgres 5432"
|
|
}
|
|
}
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Test') {
|
|
agent {
|
|
docker {
|
|
image "${BUILD_IMAGE}"
|
|
args "--network ${networkName} ${BUILD_ARGS}"
|
|
reuseNode true
|
|
}
|
|
}
|
|
steps {
|
|
script {
|
|
withCredentials([
|
|
file(credentialsId: 'tls-localhost-crt', variable: 'MB_TLS_CERT'),
|
|
file(credentialsId: 'tls-localhost-key', variable: 'MB_TLS_KEY')
|
|
]) {
|
|
sh "go test --tags=postgres -race -json -coverprofile=coverage.out -covermode=atomic ./... > test-report.out"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('SonarQube analysis') {
|
|
steps {
|
|
withSonarQubeEnv('PupHaus') {
|
|
sh "${scannerHome}/bin/sonar-scanner"
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build Snapshot') {
|
|
agent {
|
|
docker {
|
|
image "${BUILD_IMAGE}"
|
|
args "--network ${networkName} ${BUILD_ARGS}"
|
|
reuseNode true
|
|
}
|
|
}
|
|
when {
|
|
anyOf {
|
|
changeRequest()
|
|
branch 'devel'
|
|
}
|
|
}
|
|
steps {
|
|
script {
|
|
sh '/go/bin/goreleaser build --rm-dist --snapshot'
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
always {
|
|
sh """NETWORK_NAME="${networkName}" docker-compose -p ${env.BUILD_TAG} -f ${composeFile} down"""
|
|
}
|
|
}
|
|
|
|
}
|