-1
  1. List item

    pipelines:
    default:
    - step:
    name: Push changes to Commerce Cloud
    script:
    - dcu --putAll $OCCS_CODE_LOCATION --node $OCCS_ADMIN_URL --applicationKey $OCCS_APPLICATION_KEY
    - step:
    name: Publish changes Live Storefront
    image: Python 3.5.1
    script:
    python publishDCUAuthoredChanges.py -u $OCCS_ADMIN_URL -k $OCCS_APPLICATION_KEY

environment variables:

  • $OCCS_CODE_LOCATION: Path to location of all OCCS code
  • $OCCS_ADMIN_URL: URL for the administration interface on the target Commerce Cloud instance
  • $OCCS_APPLICATION_KEY: application key to use to log into the target Commerce Cloud administration interface

So I want to use Azure Dev Repository to CI / CD. in the above code block if you see I have specified - dcu & python code in two task.

dcu is nodejs third party oracle tool which needed to be used to migrate code to cloud system. I want to know how to use that tool in azure dev ops,

Second python (or) nodejs which I want to invoke to REST api to publish the changes.

So where to place those files and how do we invoke it.

*********** Update **************

I hosted the self pool agent and able to access the system. Just start executing basic bash code, but end up in two issue -

1) the git extract files from the repository it is going to _work/1/s, not sure how that path is decided. How can I change that location s 2) I did 'pwd' to the correct path but it fails in 'dcu' command. I tried with npm and other few commands it fails. But things like mkdir , rmdir it create & remove folder correctly from the desired path. when I tried the 'dcu' cmd from the terminal manually from the system it works fine as expected.

enter image description here

enter image description here

1 Answers1

1

You can follow below steps to use DCU tool and python in azure pipelines.

1, create a azure git repo to include dcu zip file and your .py files. You can follow the steps in this thread to create a azure git repo and push local files to azure repo.

2, create azure build pipeline. Please check here to create a yaml pipeline. Here is a good tutorial for you to get started.

enter image description here

To create a classic UI pipeline, please choose Use the classic editor in the pipeline setup wizard, and choose start with an Empty job to start with an empty pipeline and add your own steps.(I will use classic UI pipeline in below example.)

enter image description here

3, Click "+" and search for Extract files task to unzip the DCU zip file. Click the 3dots on the Destination folder field to select a destination folder for extracted dcu files. eg. $(agent.builddirectory). Please check my answer in this thread more information about predefined variables

enter image description here

4, click "+" to add a powershell task. Run below script in screenshot to install dcu and run dcu command. For environment variables (like $OCCS_CODE_LOCATION), please click the variables tab in below screenshot to define them

cd  $(agent.builddirectory)      #the folder where the unzipped dcu files reside. eg. $(agent.builddirectory)
npm install -g
.\dcu.cmd --putAll $(OCCS_CODE_LOCATION) --node $(OCCS_ADMIN_URL) --applicationKey $(OCCS_APPLICATION_KEY)

enter image description here

5, add Use python version task to define a python version to execute your .py file. 6, add Python script task to run your .py file. Click the 3dots on Script path field to locate your publishDCUAuthoredChanges.py file(this py file and the dcu zip file have been pushed to azure git repo in the above step 1).

enter image description here

You should be able to run the script of above question in the azure devops pipeline.

Update:

_work/1/s is the default working folder for the agent. You cannot change it. Though there are ways to change the location where the source code is cloned from git, the tasks' workingdirectory is still from the default folder.

However, You can change the workingdirectory inside the tasks. And there are predefined variables you can use to refer to the places in the agents. For below example: enter image description here

$(Agent.BuildDirectory) is mapped to c:\agent_work\1
%(Build.ArtifactStagingDirectory) is mapped to c:\agent_work\1\a
$(Build.BinariesDirectory) is mapped to c:\agent_work\1\b
$(Build.SourcesDirectory) is mapped to c:\agent_work\1\s

The .sh scripts in the _temp folder are generated automatically by the agent which contains the scripts in the bash task.

For above dcu command not found error. You can try adding dcu command path to the system variables path for your local machine's environment variables. (path in user variables cannot be found by agent jobs, For the agent use a different user account to connect to local machine) enter image description here.

Or you can use the physically path to dcu command in the bash task. For example let's say the dcu.cmd in the c:\dcu\dcu.cmd on local machine. Then in the bash task use below script to run dcu command. c:/dcu/dcu.cmd --putAll ...

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • Thanks, buddy. can you please correct me .. can we skip the DCU file extraction step by using a self-hosted agent so that one time we unzip and set up so every time it will use the same DCU unzipped file. With the above process whenever check-in happen it will unzip DCU and initiate the process. – user2993735 Feb 12 '20 at 03:12
  • 1
    Yes you can skip unzip task on self-hosted agent. You donot even need to push the DCU file to azure git repo by using self-hosted agent. You can directly use the dcu command(you need to point to the physical path of dcu.cmd. eg. `c:/{physical path}/dcu.cmd --putAll ...` ) in the powershell task. – Levi Lu-MSFT Feb 12 '20 at 03:20
  • thanks a lot, your reference was very helpful. I have updated one more question in the initial edit. – user2993735 Feb 12 '20 at 18:52
  • Hi @user2993735 I updated above answer, please check it out. – Levi Lu-MSFT Feb 13 '20 at 02:16
  • Thanks again. Can you tell me how to make sure only changes which got changed can we download from the repository. – user2993735 Feb 13 '20 at 15:40
  • If you committed you changes and pushed to azure git repo. The pipeline will download the changes. If you find above answer helpful,Could you please accept it as answer! – Levi Lu-MSFT Feb 14 '20 at 12:55