Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)
edited by

my code is deployed to the first server by gitlab-ci. I want to deploy to a different server whenever I push to the test branch. Is this possible using Gitlab CI?

1. master - 10.10.10.1

2. test - 10.10.10.2

My gitlab-ci.yml:

maven_build:

script: 

    - mvn install

    - /opt/payara41/bin/./asadmin --passwordfile /home/asadminpass --user admin undeploy myApplication-ear-1.0-SNAPSHOT

    - sudo /etc/init.d/glassfish restart

    - /opt/payara41/bin/./asadmin --passwordfile /home/asadminpass --host localhost --user admin deploy --force /home/gitlab-runner/builds/10b25461/0/myapp/myAppPrototype/myApp-ear/target/myApplication-SNAPSHOT.ear

only:

    - master

1 Answer

0 votes
by (50.2k points)

Create two different steps one with

Only: master, only: test

deploy_master:

  script: 

    - <script to deploy to master server>

  only:

    - master

deploy_test:

  script: 

    - <script to deploy to test server>

  only:

    - test

And make changes accordingly to the script to deploy to a different server.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 5, 2019 in DevOps and Agile by Abhishek_31 (12.7k points)
0 votes
1 answer
asked Feb 9, 2021 in AWS by devin (5.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers

500 comments

108k users

Browse Categories

...