Skip to content

Commit

Permalink
ci: log in to docker in vagrant boxes
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Kwiek <maciej@isovalent.com>
  • Loading branch information
nebril committed Nov 10, 2020
1 parent 019cd51 commit 238262f
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 44 deletions.
7 changes: 7 additions & 0 deletions jenkinsfiles/ginkgo-gke.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ pipeline {
}
}
}
stage('Log in to dockerhub') {
steps{
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_LOGIN} --password-stdin'
}
}
}
stage('Make Cilium images and prepare gke cluster') {
parallel {
stage('Make Cilium images') {
Expand Down
15 changes: 12 additions & 3 deletions jenkinsfiles/ginkgo-kernel.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ pipeline {
}
}
}
stage('Log in to dockerhub') {
steps{
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_LOGIN} --password-stdin'
}
}
}
stage('Make Cilium images') {
environment {
TESTDIR="${WORKSPACE}/${PROJ_PATH}/test"
Expand Down Expand Up @@ -192,9 +199,11 @@ pipeline {
)}"""
}
steps {
retry(3) {
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" timeout 15m ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" timeout 15m ./vagrant-ci-start.sh'
}
}
}
}
Expand Down
67 changes: 43 additions & 24 deletions jenkinsfiles/ginkgo-kubernetes-all.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ pipeline {
sh '/usr/local/bin/cleanup || true'
}
}
stage('Log in to dockerhub') {
steps{
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_LOGIN} --password-stdin'
}
}
}
stage('Make Cilium images') {
environment {
TESTDIR="${WORKSPACE}/${PROJ_PATH}/test"
Expand Down Expand Up @@ -137,10 +144,12 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
}
}
}
}
Expand All @@ -164,10 +173,12 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
}
}
}
}
Expand Down Expand Up @@ -268,10 +279,12 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
}
}
}
}
Expand All @@ -295,10 +308,12 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
}
}
}
}
Expand Down Expand Up @@ -398,10 +413,12 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
}
}
}
}
Expand All @@ -425,10 +442,12 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 20, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" ./vagrant-ci-start.sh'
}
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions jenkinsfiles/ginkgo-runtime-kernel.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ pipeline {
}
}
}
stage('Log in to dockerhub') {
steps{
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_LOGIN} --password-stdin'
}
}
}
stage ("Copy code and boot vms"){
options {
timeout(time: 30, unit: 'MINUTES')
Expand All @@ -120,11 +127,13 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
timeout(time: 30, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'vagrant destroy runtime --force'
sh 'KERNEL=$(python get-gh-comment-info.py "${ghprbCommentBody}" --retrieve=kernel_version | sed "s/^$/${DEFAULT_KERNEL}/") vagrant up runtime --provision'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
timeout(time: 30, unit: 'MINUTES'){
dir("${TESTDIR}") {
sh 'vagrant destroy runtime --force'
sh 'KERNEL=$(python get-gh-comment-info.py "${ghprbCommentBody}" --retrieve=kernel_version | sed "s/^$/${DEFAULT_KERNEL}/") vagrant up runtime --provision'
}
}
}
}
Expand Down
31 changes: 22 additions & 9 deletions jenkinsfiles/ginkgo.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ pipeline {
}
}
}
stage('Log in to dockerhub') {
steps{
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_LOGIN} --password-stdin'
}
}
}
stage('Make Cilium images') {
environment {
TESTDIR="${WORKSPACE}/${PROJ_PATH}/test"
Expand Down Expand Up @@ -125,9 +132,11 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
sh 'cd ${TESTDIR}; vagrant destroy runtime --force'
sh 'cd ${TESTDIR}; timeout 30m vagrant up runtime --provision'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
sh 'cd ${TESTDIR}; vagrant destroy runtime --force'
sh 'cd ${TESTDIR}; timeout 30m vagrant up runtime --provision'
}
}
}
post {
Expand Down Expand Up @@ -155,9 +164,11 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" timeout 45m ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" timeout 45m ./vagrant-ci-start.sh'
}
}
}
}
Expand All @@ -182,9 +193,11 @@ pipeline {
steps {
sh 'mkdir -p ${GOPATH}/src/github.com/cilium'
sh 'cp -a ${WORKSPACE}/${PROJ_PATH} ${GOPATH}/${PROJ_PATH}'
retry(3) {
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" timeout 45m ./vagrant-ci-start.sh'
withCredentials([usernamePassword(credentialsId: 'CILIUM_BOT_DUMMY', usernameVariable: 'DOCKER_LOGIN', passwordVariable: 'DOCKER_PASSWORD')]) {
retry(3) {
dir("${TESTDIR}") {
sh 'CILIUM_REGISTRY="$(./print-node-ip.sh)" timeout 45m ./vagrant-ci-start.sh'
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions test/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- mode: ruby -*-
# vi: set ft=ruby
Vagrant.require_version ">= 2.2.0"
# vi: set ft=ruby Vagrant.require_version ">= 2.2.0"

# The source of truth for vagrant box versions.
# Sets SERVER_BOX, SERVER_VERSION, NETNEXT_SERVER_BOXET and NEXT_SERVER_VERSION
Expand Down Expand Up @@ -33,6 +32,8 @@ $KUBEPROXY = (ENV['KUBEPROXY'] || "1")
$RACE = ENV['RACE'] || ""
$LOCKDEBUG = ENV['LOCKDEBUG'] || ""
$BASE_IMAGE = ENV['BASE_IMAGE'] || ""
$DOCKER_LOGIN = ENV['DOCKER_LOGIN'] || ""
$DOCKER_PASSWORD = ENV['DOCKER_PASSWORD'] || ""

# RAM and CPU settings
$MEMORY = (ENV['VM_MEMORY'] || "4096").to_i
Expand Down Expand Up @@ -211,7 +212,9 @@ Vagrant.configure("2") do |config|
"KUBEPROXY" => "#{$KUBEPROXY}",
"RACE" => "#{$RACE}",
"LOCKDEBUG" => "#{$LOCKDEBUG}",
"BASE_IMAGE" => "#{$BASE_IMAGE}"
"BASE_IMAGE" => "#{$BASE_IMAGE}",
"DOCKER_LOGIN" => "#{$DOCKER_LOGIN}",
"DOCKER_PASSWORD" => "#{$DOCKER_PASSWORD}"
}
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/provision/k8s_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

set -e

if ! [[ -z $DOCKER_LOGIN && -z $DOCKER_PASSWORD ]]; then
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_LOGIN}" --password-stdin
fi

HOST=$(hostname)
export HELM_VERSION="3.3.4"
export TOKEN="258062.5d84c017c9b2796c"
Expand Down
4 changes: 4 additions & 0 deletions test/provision/runtime_install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
set -e

if ! [[ -z $DOCKER_LOGIN && -z $DOCKER_PASSWORD ]]; then
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_LOGIN}" --password-stdin
fi

HOST=$(hostname)
PROVISIONSRC="/tmp/provision"

Expand Down

0 comments on commit 238262f

Please sign in to comment.