Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eic_container
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
containers
eic_container
Commits
7c591689
Commit
7c591689
authored
1 year ago
by
Wouter Deconinck
Browse files
Options
Downloads
Patches
Plain Diff
Delete docker_login.sh
parent
02f1ae46
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gitlab-ci/docker_login.sh
+0
-110
0 additions, 110 deletions
gitlab-ci/docker_login.sh
with
0 additions
and
110 deletions
gitlab-ci/docker_login.sh
deleted
100755 → 0
+
0
−
110
View file @
02f1ae46
#!/bin/bash
## Resilient docker login with multiple progressive retries in case of TLS issues
function
print_the_help
{
echo
"USAGE: -u user -p -password [...] [registry]"
echo
"ARGUMENTS:"
echo
" -u,--user Registry user"
echo
" -p,--password Registry password"
echo
" --ci Login to internal CI registry; -u, -p and positional are ignored"
echo
" -t,--time Time interval (in seconds) between attempts"
echo
" (doubled each time), default: 5"
echo
" -n,--n-attempts Number of attempts, default: 5"
echo
" -h,--help Print this message"
echo
" positional Registry name (will use dockerhub if none given)"
echo
""
echo
" Login to registry."
echo
""
echo
"EXAMPLE: ./docker_login.sh -u
\$
CI_REGISTRY_USER -p
\$
CI_REGISTRY_PASSWORD
\$
CI_REGISTRY"
exit
}
REGISTRY
=
REG_USER
=
REG_PASSWORD
=
NTRIES
=
5
TIME
=
5
CI
=
while
[
$#
-gt
0
]
;
do
key
=
$1
case
$key
in
-u
|
--user
)
REG_USER
=
$2
shift
shift
;;
-p
|
--password
)
REG_PASSWORD
=
$2
shift
shift
;;
--ci
)
CI
=
1
shift
;;
-t
|
--time
)
TIME
=
$2
shift
shift
;;
-n
|
--n-attempts
)
NTRIES
=
$2
shift
shift
;;
-h
|
--help
)
print_the_help
exit
0
;;
-
*
)
echo
"ERROR: unknown flag:
$key
"
echo
"use --help for more info"
exit
1
;;
*
)
REGISTRY+
=
"
$1
"
shift
;;
esac
done
## only sanizize input if not in CI registry mode
if
[
-z
$CI
]
;
then
if
[
-z
$REG_USER
]
;
then
echo
"ERROR: no username given, please use -u <USER>"
print_the_help
exit
1
fi
if
[
-z
$REG_PASSWORD
]
;
then
echo
"ERROR: no password given, please use -p <PASSWORD>"
print_the_help
exit
1
fi
else
REGISTRY
=
$CI_REGISTRY
REG_USER
=
$CI_REGISTRY_USER
fi
while
[
$NTRIES
!=
0
]
;
do
if
[
-z
$CI
]
;
then
echo
$REG_PASSWORD
| docker login
-u
$REG_USER
\
--password-stdin
$REGISTRY
\
&&
break
\
||
echo
"Login failed, retrying in
$TIME
seconds..."
else
echo
$CI_REGISTRY_PASSWORD
| docker login
-u
$REG_USER
\
--password-stdin
$REGISTRY
\
&&
break
\
||
echo
"Login failed, retrying in
$TIME
seconds..."
fi
sleep
${
TIME
}
s
TIME
=
$((
TIME
*
2
))
NTRIES
=
$((
NTRIES
-
1
))
done
if
[
$NTRIES
=
0
]
;
then
echo
"Failed to login to registry
$REGISTRY
"
exit
1
fi
echo
"Docker login to
$REGISTRY
successful"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment