TransparentWorld / Issues

TransparentWorld-Issues
MIT License
0 stars 0 forks source link

Create script and call it from jenkins for deployment #5

Closed farley13 closed 7 years ago

farley13 commented 8 years ago

We should add timing for each step as well - so we know what steps are taking the longest - build are about 20 minutes a piece which isn't bad - but with some caching of artifacts can likely be improved quite a bit.

Current Jenkins script is:

cd WorldStageWebsite

export APP_VERSION=$(git describe --long --tags --dirty --always)

export APP_ENVIRONMENT=DEV docker-compose run -e APP_VERSION web bin/activator test

$(aws ecr get-login --profile jenkins) sudo chown -R $USER:$USER . bin/activator clean docker:publish

export APP_ENVIRONMENT=TEST docker-compose run --no-deps -e APP_VERSION web bin/activator test ecs-cli configure --profile jenkins --region us-east-1 --cluster $APP_ENVIRONMENT ecs-cli compose --debug --project-name worldstagewebsite --file deployment/web.yml service up

export APP_ENVIRONMENT=PROD docker-compose run --no-deps -e APP_VERSION web bin/activator test ecs-cli configure --profile jenkins --region us-east-1 --cluster $APP_ENVIRONMENT ecs-cli compose --debug --project-name worldstagewebsite --file deployment/web.yml service up

docker-compose down -v unset APP_VERSION APP_ENVIRONMENT

akarasev commented 7 years ago

After I moved the commands into a shell script and tried to rewrite Jenkins config like this:

cd WorldStageWebsite
./run_amazon_deploy.sh

Jenkins lost the ability to mark build as failed if test didn't pass or/and build wasn't successfull.

After some reading, I've realised that Jenkins uses exit status and mark build as successful if code is 0. If we call ./run_amazon_deploy.sh, the result will be 0 as the script itself executed normally.

Another issue, current script may cause that TEST and PROD may have diffrent versions. E.g. testing PROD environment failed, but TEST already deployed.

So, I'd like just to rewrite commands into Jenkins config as following:

export APP_ENVIRONMENT=DEV
docker-compose run web bin/activator test
export APP_ENVIRONMENT=TEST
docker-compose run --no-deps web bin/activator test
export APP_ENVIRONMENT=PROD
docker-compose run --no-deps web bin/activator test

export APP_VERSION=$(git describe --long --tags --dirty --always)
$(aws ecr get-login --profile jenkins)
sudo chown -R $USER:$USER .
bin/activator docker:publish

... depoyment using ecs-cli goes here ...

What do you think about it?

farley13 commented 7 years ago

Can we just use " set -e " in the script and fail fast if any step fails? I'd prefer having as much in jenkins as possible scripted in source control

For TEST vs PROD having different versions - do you mean you will spin up new VMs for both, then test both and then swap both into rotation in the load balancer? I wasn't clear on what the fix for that issue was. One thing we definitely want would be making sure if the deploy to test fails for any reason (build, deploy, docker, startup, tests) we shouldn't deploy to production and we should abort immediately. The deploy to test should prevent issues from getting to production (like say now! when test is broken, but production did not get the update because of that).

On Wed, Nov 9, 2016 at 9:52 PM, akarasev notifications@github.com wrote:

After I moved the commands into a shell script and tried to rewrite Jenkins config like this:

cd WorldStageWebsite ./run_amazon_deploy.sh

Jenkins lost the ability to mark build as failed if test didn't pass or/and build wasn't successfull.

After some reading, I've realised that Jenkins uses exit status http://www.tldp.org/LDP/abs/html/exit-status.html and mark build as successful if code is 0. If we call ./run_amazon_deploy.sh, the result will be 0 as the script itself executed normally.

Another issue, current script may cause that TEST and PROD may have diffrent versions. E.g. testing PROD environment failed, but TEST already deployed.

So, I'd like just to rewrite commands into Jenkins config as following:

export APP_ENVIRONMENT=DEV docker-compose run web bin/activator test export APP_ENVIRONMENT=TEST docker-compose run --no-deps web bin/activator test export APP_ENVIRONMENT=PROD docker-compose run --no-deps web bin/activator test

export APP_VERSION=$(git describe --long --tags --dirty --always) $(aws ecr get-login --profile jenkins) sudo chown -R $USER:$USER . bin/activator docker:publish

... depoyment using ecs-cli goes here ...

What do you think about it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TransparentWorld/Issues/issues/5#issuecomment-259588931, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYh1B9ji5xswJiB2DpfTbVWckfKCMuKks5q8obkgaJpZM4JxNfr .