Skip to content
Snippets Groups Projects

Resolve "Update deprecated deploy job"

Merged Iñigo Moreno i Caireta requested to merge 38-update-deprecated-deploy-job into master
1 file
+ 9
9
Compare changes
  • Side-by-side
  • Inline
@@ -14,24 +14,51 @@
@@ -14,24 +14,51 @@
CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Wno-ignored-attributes -Wno-int-in-bool-context
CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Wno-ignored-attributes -Wno-int-in-bool-context
.industrial_ci_deploy:
.ddeploy:
extends: .industrial_ci
stage: deploy
variables:
variables:
AFTER_SCRIPT: "wget -q -O - https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/pre-deploy-cleanup.bash | bash"
DOCKER_PUSH_REGISTRY: ${ARTIFACT_DOCKER_URL}
DOCKER_COMMIT: industrial_ci_image
DOCKER_PUSH_NAME: ${CI_PROJECT_PATH}
 
DOCKER_PUSH_TAG: ${CI_COMMIT_REF_SLUG}
 
DDEPLOY_YAML: ddeploy.yaml
 
before_script:
 
- apk add --update python3 git py3-pip git-lfs
 
# forward the SSH authentication into the Docker executor
 
- "which ssh-agent || ( apk update && apk add openssh-client )"
 
- eval $(ssh-agent -s)
 
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
 
- mkdir -p ~/.ssh
 
- echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
 
- chmod 700 ~/.ssh
 
# setup LFS authentication
 
- git lfs install
 
- git config --global credential.helper store
 
- echo https://$ARTIFACT_CI_USER:$ARTIFACT_CI_TOKEN@artifact.tecnalia.com > ~/.git-credentials
 
# install ddeploy
 
- pip install git+ssh://git@git.code.tecnalia.com/tecnalia_robotics/flexbotics/flexbotics_utils/ddeploy.git@v0.1.0
 
- docker login ${ARTIFACT_DOCKER_URL} -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
script:
script:
- .ci_config/gitlab.sh
# Run ddeploy
- cd $(mktemp -d)
- ddeploy --yaml ${DDEPLOY_YAML}
- wget https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/-/archive/master/gitlab_templates-master.zip
# Get ID of image created by ddeploy
- unzip gitlab_templates-master.zip && cd gitlab_templates-master/deploy
- 'DOCKER_ID=$(docker images --format="{{.ID}}" | head -1)'
- cd base
# Tag and push with the branch or tag name.
- chmod a+x ros_entrypoint.bash
- echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}"
- docker build -t ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME} .
- docker tag ${DOCKER_ID} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}
- docker push ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME}
- docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}
- cd ..
# Tag and push with commit sha
- cd dev
- echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}"
- docker build --build-arg APPLICATION_IMAGE=${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME} -t ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME}-dev .
- docker tag ${DOCKER_ID} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}
- docker push ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME}-dev
- docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}
- cd ..
# Tag and push with latest only if it's on the default branch
 
- >
 
if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
 
echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest"
 
docker tag ${DOCKER_ID} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest &&
 
docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest;
 
fi
rules:
rules:
- if: $DEPLOY
- if: $CI_COMMIT_TAG
 
when: always
 
- when: manual
 
allow_failure: true
Loading