Skip to content

Commit

Permalink
Jenkins: Merge build scripts for distribution images into single scri…
Browse files Browse the repository at this point in the history
…pted pipeline (#178)

* Jenkins: Merge build scripts for distribution images into single scripted pipeline

* Add git checkout and SSH agent wrapper

* Delete obsolete pipelines and scripts

* Convert back to declarative pipeline

It's a better match than scripted pipeline for this job after all.

* Jenkins: added ecr-login stage

Co-authored-by: Felice Dibattista <fb@concordium.com>
  • Loading branch information
bisgardo and fdibat authored Oct 4, 2021
1 parent 5701471 commit 8c942ff
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 213 deletions.
69 changes: 69 additions & 0 deletions jenkinsfiles/distribution-image.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Parameters:
// - environment
// - image_tag (default: "latest")
// - base_image_tag (default: "latest")
// - static_libraries_image_tag (default: "latest")
// - ghc_version (default: "8.10.4")
// - genesis_ref (default: "master")
// - genesis_path

@Library('concordium-pipelines') _
pipeline {
agent any

environment {
image_name = "${environment}-node"
domain = "${concordiumDomain(environment)}"
}

stages {
stage('ecr-login') {
steps {
sh 'aws ecr get-login-password \
--region eu-west-1 \
| docker login \
--username AWS \
--password-stdin 192549843005.dkr.ecr.eu-west-1.amazonaws.com'
}
}
stage('build') {
steps {
// Using '--no-cache' because we're cloning genesis data
// and BuildKit (and '--ssh default') because the repo is on GitLab.
sshagent (credentials: ['jenkins-gitlab-ssh']) {
sh '''\
DOCKER_BUILDKIT=1 docker build \
--build-arg environment="${domain}"\
--build-arg base_image_tag="${base_image_tag}" \
--build-arg static_libraries_image_tag="${static_libraries_image_tag}" \
--build-arg ghc_version="${ghc_version}" \
--build-arg genesis_ref="${genesis_ref}" \
--build-arg genesis_path="${genesis_path}" \
--label base_image_tag="${base_image_tag}" \
--label static_libraries_image_tag="${static_libraries_image_tag}" \
--label ghc_version="${ghc_version}" \
--label genesis_ref="${genesis_ref}" \
--label genesis_path="${genesis_path}" \
-t "concordium/${image_name}:${image_tag}" \
-f scripts/distribution/builder.Dockerfile \
--ssh default\
--no-cache \
.
'''.stripIndent()
}
}
}

stage('push') {
environment {
file = "${image_name}-${image_tag}.tar.gz"
}
steps {
sh '''\
docker save concordium/"${image_name}:${image_tag}" | gzip > "${file}"
aws s3 cp "${file}" s3://distribution.${domain}/image/ --grants=read=uri=http://acs.amazonaws.com/groups/global/AllUsers
'''.stripIndent()
}
}
}
}
25 changes: 0 additions & 25 deletions jenkinsfiles/mainnet.Jenkinsfile

This file was deleted.

25 changes: 0 additions & 25 deletions jenkinsfiles/stagenet.Jenkinsfile

This file was deleted.

25 changes: 0 additions & 25 deletions jenkinsfiles/testnet.Jenkinsfile

This file was deleted.

46 changes: 0 additions & 46 deletions scripts/distribution/build-and-push-mainnet.sh

This file was deleted.

46 changes: 0 additions & 46 deletions scripts/distribution/build-and-push-stagenet.sh

This file was deleted.

46 changes: 0 additions & 46 deletions scripts/distribution/build-and-push-testnet.sh

This file was deleted.

0 comments on commit 8c942ff

Please sign in to comment.