Commit 3030a66c authored by Administrator's avatar Administrator

Update .gitlab-ci.yml

parent 76c5e7f7
Pipeline #56 failed with stages
in 26 seconds
image: docker:latest image: docker:latest
services: variables:
- docker:dind REPOSITORY_URL: 751503455312.dkr.ecr.us-west-2.amazonaws.com/altimetrik-ecs
REGION: us-west-2
TASK_DEFINTION_NAME: first-run-task-definition
CLUSTER_NAME: playground-ecs
cache: SERVICE_NAME: Test
paths:
- .m2/
services:
- docker:dind
before_script: before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - apk add --no-cache curl jq python py-pip
- pip install awscli
- $(aws ecr get-login --no-include-email --region "${REGION}")
- IMAGE_TAG="$(echo $CI_COMMIT_SHA | head -c 8)"
stages:
- build
- deploy
build: build:
stage: build stage: build
script: script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" . - echo "Building image..."
- docker tag docker:latest "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest" - docker build -t $REPOSITORY_URL:latest .
- docker push "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest" - echo "Tagging image..."
- docker tag $REPOSITORY_URL:latest $REPOSITORY_URL:$IMAGE_TAG
#sonar: - echo "Pushing image..."
# stage: test - docker push $REPOSITORY_URL:latest
# script: - docker push $REPOSITORY_URL:$IMAGE_TAG
# - mvn --batch-mode verify sonar:sonar -Dsonar.exclusions="pom.xml" -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN only:
- master
deploy: deploy:
stage: deploy stage: deploy
script: script:
- docker pull "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest" - echo $REPOSITORY_URL:$IMAGE_TAG
- docker run -d "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME:latest" - TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition "$TASK_DEFINTION_NAME" --region "${REGION}")
- NEW_CONTAINER_DEFINTIION=$(echo $TASK_DEFINITION | python $CI_PROJECT_DIR/update_task_definition_image.py $REPOSITORY_URL:$IMAGE_TAG)
- echo "Registering new container definition..."
- aws ecs register-task-definition --region "${REGION}" --family "${TASK_DEFINTION_NAME}" --container-definitions "${NEW_CONTAINER_DEFINTIION}"
- echo "Updating the service..."
- aws ecs update-service --region "${REGION}" --cluster "${CLUSTER_NAME}" --service "${SERVICE_NAME}" --task-definition "${TASK_DEFINTION_NAME}"
only: only:
- master - master
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment