Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

PIPE azure-vm-linux-script-deploy run shell script?

Usama Habib July 16, 2019

Hi i am using bitbucket pipelines to deploy code to my website running in an azure linux vm. i have been through this link and its related all sources 

https://bitbucket.org/microsoft/azure-vm-linux-script-deploy/src/master/

what i found and is confusing a bit is that it says it downloads and run a script in azure vm connected by secure principal.

My concern is that i have a script present the on linux server i want to run that script by logging in to my linux VM. is it possible that i can do that.

Any little help in this regard will be highly appreciated it a bit confusing point.

THANKS

1 answer

1 accepted

0 votes
Answer accepted
nikesh July 22, 2019

Your pipeline file will look like this:

image: maven:3.3.9

pipelines:
custom:
default:
- step:
name: trigger script
script: # Modify the commands below to build your repository.
- pipe: microsoft/azure-vm-linux-script-deploy:1.0.1
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
AZURE_RESOURCE_GROUP: $AZURE_RESOURCE_GROUP
AZURE_VM_NAME: $AZURE_VM_NAME
AZURE_EXTENSION_COMMAND: './reposcript.sh'
AZURE_EXTENSION_FILES: 'reposcript.sh'
AZURE_FORCE_UPDATE: 'true'
AZURE_NO_WAIT: 'true'
AZURE_CLEANUP: 'true'
DEBUG: 'true'

 

You can call your script on machine from reposcript.sh 

#!/bin/bash
cd /home/mydir
./myscript.sh
echo 'my script is called on vm'
Usama Habib July 22, 2019

thanks nikesh it seem pretty clear, will try this

nikesh July 22, 2019

Do let me know if it works for you. 

Usama Habib July 22, 2019

one small thing which is a concern is it necessary to use the image mentioned? or i can use my working image. 

Referring to this line

image: maven:3.3.9
nikesh July 22, 2019

Yea.  You can use your image. It just representational purpose. You can ignore that.

Like • Usama Habib likes this
nikesh July 22, 2019

If script is not executed then set  azure_no_wait to false. By doing this your reposcript will wait for your myscript to finish before deleting reposcript from storage container. 

In my case, reposcript was gettign deleted from temporary storage account before executing instructions in it. Took a while to figure it out. Hope this helps.

 AZURE_NO_WAIT: 'false'

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events