Compare commits
2 commits
0fc4690cd1
...
afffb8c90f
Author | SHA1 | Date | |
---|---|---|---|
afffb8c90f | |||
568943f176 |
3 changed files with 34 additions and 2 deletions
18
cd.sh
18
cd.sh
|
@ -27,6 +27,7 @@ case "${CD_OS_NAME}" in
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
#
|
||||||
[ "${CI_SERVER_URL}" ] && CD_REPOSITORIES_URL="${CI_SERVER_URL}"
|
[ "${CI_SERVER_URL}" ] && CD_REPOSITORIES_URL="${CI_SERVER_URL}"
|
||||||
[ "${GITHUB_SERVER_URL}" ] && CD_REPOSITORIES_URL="${GITHUB_SERVER_URL}"
|
[ "${GITHUB_SERVER_URL}" ] && CD_REPOSITORIES_URL="${GITHUB_SERVER_URL}"
|
||||||
if [ "${CD_REPOSITORIES_URL}" ] ; then
|
if [ "${CD_REPOSITORIES_URL}" ] ; then
|
||||||
|
@ -35,6 +36,23 @@ else
|
||||||
echo 'CD_REPOSITORIES_URL'
|
echo 'CD_REPOSITORIES_URL'
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
#
|
||||||
|
[ "${CI_PROJECT_NAME}" ] && CD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
||||||
|
[ "${GITHUB_REPOSITORY}" ] \
|
||||||
|
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||||
|
if [ "${CD_PROJECT_NAME}" ] ; then
|
||||||
|
CD_PROJECT_URL="${CD_REPOSITORIES_URL}/${CD_PROJECT_NAME}"
|
||||||
|
else
|
||||||
|
echo 'CD_PROJECT_NAME'
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
[ "${CI_COMMIT_BRANCH}" ] && CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||||
|
[ "${GITHUB_REF_NAME}" ] && CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||||
|
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
|
||||||
|
echo 'CD_PROJECT_BRANCH'
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
function cd_step {
|
function cd_step {
|
||||||
if [ "${1}" ] ; then
|
if [ "${1}" ] ; then
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from rwx import ps
|
||||||
|
|
||||||
COMMANDS_PREFIX = 'cd-'
|
COMMANDS_PREFIX = 'cd-'
|
||||||
|
|
||||||
|
|
||||||
|
def cd_clone_branch():
|
||||||
|
ps.run('git',
|
||||||
|
'clone',
|
||||||
|
'--branch', os.environ['CD_PROJECT_BRANCH'],
|
||||||
|
'--',
|
||||||
|
os.environ['CD_PROJECT_URL'],
|
||||||
|
'.',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def cd_list_environment():
|
def cd_list_environment():
|
||||||
for variable, value in sorted(os.environ.items()):
|
for variable, value in sorted(os.environ.items()):
|
||||||
print(variable, '=', value)
|
print(variable, '=', value)
|
||||||
|
@ -10,5 +22,8 @@ def cd_list_environment():
|
||||||
|
|
||||||
def install_commands(path):
|
def install_commands(path):
|
||||||
user = '/usr/local/bin'
|
user = '/usr/local/bin'
|
||||||
for command in ['list-environment']:
|
for command in [
|
||||||
|
'clone-branch',
|
||||||
|
'list-environment',
|
||||||
|
]:
|
||||||
os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}'))
|
os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}'))
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
env | sort
|
|
Loading…
Reference in a new issue