I have created triggered jobs in my projects that deploys my tomcat app to a web server.
There is a variable in the project called: web_server.
This variable holds the name of the designated web server where the app gets deployed to.
I want to create some kind of startup script that will talk to gitlab and when a new server is built it will deploy the applications that are are “assigned” to it.
Question: Is there a way through the API or webhook or plugin, that I can send a command that says: trigger pipelines for projects with the web_server variable set to Web5?
@gitlab-pano Seems like this is a valid use case based on what you’ve described. Can you share your gitlab-ci.yml file to provide some more details on the jobs that are being run?
J
This is my deployment CI. It will deploy only the one application. I currently use Rundeck to allow users to trigger the deployment.
stages:
- undeploy
- copy
- deploy
- updatedns
undeploy_existing_app:
stage: undeploy
script:
- wget --http-user=username --http-password=password! "https://$web_server.panosoft.com/manager/text/undeploy?path=/$CI_PROJECT_NAME" -O -
tags:
- dedicated
copy_files:
stage: copy
script:
#Copy Configs
- cd Configs
- sed -i -e "s/web_server/$web_server/g" $CI_PROJECT_NAME.xml
- scp -r -i /home/gitlab-runner/.ssh/InstanceMGMT.pem [!.]* ubuntu@$web_server.panosoft.com:/app/apache-tomcat-7.0.42/conf/Catalina/$web_server.panosoft.com/
#copy war
- ssh -i /home/gitlab-runner/.ssh/InstanceMGMT.pem $web_server.panosoft.com "cp /app/jenkins/$CI_PROJECT_NAME/workspace/$CI_PROJECT_NAME.war /app/webfiles/wars/$CI_PROJECT_NAME.war"
tags:
- dedicated
deploy_war:
stage: deploy
script:
#Deploy war
- wget --http-user=username --http-password=password! "https://$web_server.panosoft.com/manager/text/deploy?war=file:/app/webfiles/wars/$CI_PROJECT_NAME.war&path=/$CI_PROJECT_NAME" -O -
only:
- triggers
environment: production
tags:
- dedicated
update_dns:
stage: updatedns
script:
- |-
TARGET_ZONEID="REDACTED"; TARGET_FQDN="$company.panosoft.com."; TARGET_SERVER="$web_server.panosoft.com."; echo '{ "Comment": "DDNS update", "Changes":[ { "Action": "UPSERT", "ResourceRecordSet": { "ResourceRecords": [ { "Value": "'"$TARGET_SERVER"'" } ], "Name": "'"$TARGET_FQDN"'", "Type": "CNAME", "TTL": 60} } ] }' | aws route53 change-resource-record-sets --hosted-zone-id "$TARGET_ZONEID" --change-batch file:///dev/stdin
- |-
TARGET_ZONEID="REDACTED"; TARGET_FQDN="$company.panosoft.com."; TARGET_SERVER="$web_server.panosoft.com."; echo '{ "Comment": "DDNS update", "Changes":[ { "Action": "UPSERT", "ResourceRecordSet": { "ResourceRecords": [ { "Value": "'"$TARGET_SERVER"'" } ], "Name": "'"$TARGET_FQDN"'", "Type": "CNAME", "TTL": 60} } ] }' | aws route53 change-resource-record-sets --hosted-zone-id "$TARGET_ZONEID" --change-batch file:///dev/stdin
only:
- triggers
environment: full_deploy
tags:
- dedicated```