diff --git a/Jenkinsfile b/Jenkinsfile index f289b79..211f069 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,6 @@ #!/usr/bin/env groovy +def rubies = ['2.3.0', '2.3.1', '2.2.5', 'jruby', 'jruby-9.1.2.0', 'rubinius'] node('docker') { checkout scm @@ -7,17 +8,29 @@ node('docker') { stage 'Prepare base RVM container' sh './build-base.sh' - stage 'Build Containers for Rubies' - sh './build-rubies.sh' + stage 'Push base RVM container' + sh './push-base.sh' - stage 'Publish Containers' - /* Using credentials with the ID 'dockerhub' from the Jenkins installation */ - withCredentials([[$class: 'UsernamePasswordMultiBinding', - credentialsId: 'dockerhub', - passwordVariable: 'DOCKERHUB_TOKEN', - usernameVariable: 'DOCKERHUB_USERNAME']]) { - /* Our variables be exposed in the environment and we must log in before trying to publish to Dockerhub */ - sh 'docker login --username=${DOCKERHUB_USERNAME} --email=tyler@monkeypox.org --password=${DOCKERHUB_TOKEN}' - sh './push-rubies.sh' + stage 'Build Containers for Rubies' + def stepsForParallel = [:] + for (int i = 0; i < rubies.size(); i++) { + def ruby = rubies.get(i) + stepsForParallel[ruby] = { + node { + sh "./build-rubies.sh ${ruby}" + sh './pu + /* Using credentials with the ID 'dockerhub' from the Jenkins installation */ + withCredentials([[$class: 'UsernamePasswordMultiBinding', + credentialsId: 'dockerhub', + passwordVariable: 'DOCKERHUB_TOKEN', + usernameVariable: 'DOCKERHUB_USERNAME']]) { + /* Our variables be exposed in the environment and we must log in before trying to publish to Dockerhub */ + sh 'docker login --username=${DOCKERHUB_USERNAME} --email=tyler@monkeypox.org --password=${DOCKERHUB_TOKEN}' + sh "./push-rubies.sh ${ruby}" + } + } + } } + /* Fan everything out like crazy */ + parallel(stepsForParallel) } diff --git a/build-rubies.sh b/build-rubies.sh index 1884021..a32de12 100755 --- a/build-rubies.sh +++ b/build-rubies.sh @@ -6,6 +6,10 @@ source ./rubies mkdir -p work +if [ -n $1 ]; then + RUBIES=( "${1}" ) +fi; + for RUBY in "${RUBIES[@]}"; do DOCKERFILE="work/dockerfile-${RUBY}" cat > $DOCKERFILE < Pushing ${IMAGE_TAG}:${RUBY}" diff --git a/rubies b/rubies index 4d7e8ad..06b9377 100644 --- a/rubies +++ b/rubies @@ -1,5 +1,5 @@ #!/usr/bin/env bash -export RUBIES=( 2.3.0 jruby jruby-9.1.2.0 ruby-head) +export RUBIES=( 2.3.0 2.3.1 2.2.5 jruby jruby-9.1.2.0 ruby-head) export IMAGE_TAG="rtyler/rvm"