Skip to content

Instantly share code, notes, and snippets.

@Meg4R0M
Last active July 17, 2019 18:18
Show Gist options
  • Save Meg4R0M/90e87c39f24b17b63690d2cb1e8802e2 to your computer and use it in GitHub Desktop.
Save Meg4R0M/90e87c39f24b17b63690d2cb1e8802e2 to your computer and use it in GitHub Desktop.
ci function
.cicd_before_running: &cicd_before_running |
function prereq() {
echo "Preparing environment"
## Login to Harbor registry
echo "$DOCKER_PASSWORD" | docker login docker-registry.kaliop.net -u "$DOCKER_USER" --password-stdin
## Run ssh-agent (inside the build environment)
eval $(ssh-agent -s)
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
echo "$SSH_ANCA_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
## Create the SSH directory and give it the right permissions
mkdir -p ~/.ssh
chmod 700 ~/.ssh
## Add remote server ssh host key to known hosts
ssh-keyscan -H '10.249.8.200' >> ~/.ssh/known_hosts
ssh-keyscan -H '10.34.200.214' >> ~/.ssh/known_hosts
}
## Deploy on dev (rec6) if merge ok on branches dev
deploy_rec:
image: "klabs/automation"
stage: deploy_rec
tags:
- kaliop-deploy-clients
script:
- *cicd_before_running
- prereq
- ssh -v -A -o StrictHostKeyChecking=no -o ProxyCommand='ssh -A site@10.34.200.214 -W %h:%p' root@172.17.214.200 "cd /opt/anca-deployment/ansible/ && ansible-playbook playbook_uat_composer_app.yml -vvv --tags=composer_app_update"
- echo "Deployed with success !!!"
when: on_success
only:
- dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment