Attempt at adding Jenkins CI
All checks were successful
ecodash/pipeline/head This commit looks good
All checks were successful
ecodash/pipeline/head This commit looks good
This commit is contained in:
parent
4b3af653b8
commit
33f09c93bd
7 changed files with 153 additions and 168 deletions
76
jenkins/Jenkinsfile
vendored
Normal file
76
jenkins/Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
pipeline {
|
||||
|
||||
agent any
|
||||
|
||||
environment {
|
||||
USER='user'
|
||||
PASSWORD='password'
|
||||
DOCKER_REGISTRY='git.massivebox.net'
|
||||
BUILDER_NAME='mbuilder'
|
||||
SERVICE='ecodash/ecodash'
|
||||
TAG='latest'
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Run linter and build') {
|
||||
agent { docker { image 'golang' } }
|
||||
steps {
|
||||
git url: 'https://git.massivebox.net/ecodash/ecodash'
|
||||
//sh 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin'
|
||||
sh 'go mod tidy'
|
||||
//sh 'golangci-lint run'
|
||||
sh 'env GOOS=linux GOARCH=amd64 go build -o app src/main/main.go'
|
||||
stash includes: 'app', name: 'ecodash-x86'
|
||||
sh 'env GOOS=linux GOARCH=arm go build -o app src/main/main.go'
|
||||
stash includes: 'app', name: 'ecodash-arm'
|
||||
stash includes: 'templates/**', name: 'templates'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('Build x86 container') {
|
||||
steps {
|
||||
sh 'curl -L -o Dockerfile https://pasty.nikko.cf/UYU39i/raw'
|
||||
unstash 'ecodash-x86'
|
||||
unstash 'templates'
|
||||
sh 'docker build -t $DOCKER_REGISTRY/$SERVICE:$TAG .'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Prepare buildx') {
|
||||
steps {
|
||||
sh """
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
|
||||
docker context create $BUILDER_NAME
|
||||
docker context use $BUILDER_NAME
|
||||
docker buildx create $BUILDER_NAME
|
||||
docker buildx use $BUILDER_NAME
|
||||
docker buildx inspect --bootstrap
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build arm container') {
|
||||
steps {
|
||||
sh 'curl -L -o Dockerfile https://pasty.nikko.cf/UYU39i/raw'
|
||||
unstash 'ecodash-arm'
|
||||
unstash 'templates'
|
||||
sh 'docker buildx build --platform linux/arm64 -t $DOCKER_REGISTRY/$SERVICE:$TAG .'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// cleanup
|
||||
sh """
|
||||
docker context rm -f $BUILDER_NAME
|
||||
docker buildx use default
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue