Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add docker login for smoke tests #3251

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions integration/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import java.util.Random

pipeline {

agent none

options {
buildDiscarder logRotator(
daysToKeepStr: '16',
numToKeepStr: '10'
)
daysToKeepStr: '16',
numToKeepStr: '10'
)
}
parameters {
string(name: 'VERSION', defaultValue: '', description: 'Version')
Expand Down Expand Up @@ -53,6 +55,9 @@ pipeline {
cleanWs()
stopAndRemoveDockers()
setupWorkspace()
retryWithBackoff(3) {
dockerLogin()
}
}
}
stage('Install NATIVE pkg') {
Expand Down Expand Up @@ -111,6 +116,9 @@ pipeline {
cleanWs()
stopAndRemoveDockers()
setupWorkspace()
retryWithBackoff(3) {
dockerLogin()
}
}
}
stage('Install RPM pkg') {
Expand Down Expand Up @@ -166,6 +174,9 @@ pipeline {
cleanWs()
stopAndRemoveDockers()
setupWorkspace()
retryWithBackoff(3) {
dockerLogin()
}
}
}
stage('Install Docker') {
Expand Down Expand Up @@ -226,6 +237,9 @@ pipeline {
cleanWs()
stopAndRemoveDockers()
setupWorkspace()
retryWithBackoff(3) {
dockerLogin()
}
}
}
stage('Install Docker FIPS') {
Expand Down Expand Up @@ -284,7 +298,7 @@ def void stopAndRemoveDockers() {
sh '''
for container_id in $(docker ps -a -q);do docker stop $container_id;done
for container_id in $(docker ps -a -q);do docker rm $container_id;done
docker system prune --force --volumes
docker system prune --all --force --volumes
volumes=$(docker volume ls -qf dangling=true)
if [ "$volumes" ]; then
docker volume rm $volumes
Expand All @@ -308,4 +322,30 @@ def void printNodeInfo() {
socket.connect(InetAddress.getByName("8.8.8.8"), 10002);
nodeIp = socket.getLocalAddress().getHostAddress();
println("The Node IP Address is: ${nodeIp}")
}

def void dockerLogin() {
withDockerRegistry([credentialsId: "DockerHub", url: ""]) {
sh 'docker login'
}
}

def void retryWithBackoff(int retries, Closure body) {
int attempt = 0
Random random = new Random()
while (attempt < retries) {
try {
body.call()
return
} catch (Exception e) {
attempt++
if (attempt >= retries) {
throw e
}
int randomDelay = random.nextInt(15) // Random delay between 0 and 15 seconds
int backoffTime = 30 + randomDelay // Base backoff of 30 seconds plus random delay
println("Retry attempt ${attempt}, sleeping for ${backoffTime} seconds")
sleep time: backoffTime, unit: 'SECONDS'
}
}
}
2 changes: 1 addition & 1 deletion jenkins/artifacts/jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def void stopAndRemoveDockers() {
rm -rf /opt/home/nightly/
mkdir -p /opt/home/nightly/
for container_id in $(docker ps -a -q);do docker stop $container_id;done
docker system prune --force --volumes
docker system prune --all --force --volumes
volumes=$(docker volume ls -qf dangling=true)
if [ "$volumes" ]; then
docker volume rm $volumes
Expand Down