-v $(Build.SourcesDirectory):/here -v $(Agent.TempDirectory):/there casthighlight/cli:latest --sourceDir here --workingDir there --skipUpload
You can run Docker on most of operating systems such as Linux, Windows, MacOS, etc. In the meantime, the Docker image comes with its own embedded OS which has a different file system. Hence the need to map your local file system with the image file system. To do so, you’ll need to use the ‘-v’ (for ‘volume’) for each Highlight scan option where the file system is used. This is mainly the case for specifying the source directory (--sourceDir) and the working directory (--workingDir) where the scan results and log files will be produced. So, simply pass:
-v {your_local_directory}:/{docker_alias_for_this_directory}
These volumes must be defined prior to running the image per se (so that Docker will know and access the paths). Then, specify the image name (casthighlight/cli) and the version of the imshoage to be run as a container (separated by “:”).Once these initial docker-specific settings are done, simply pass the rest of the Highlight CLI options you already know, making sure you used the defined Docker directory aliases for --sourceDir and --workingDir.The final Docker command in your Azure DevOps step would look like this for an automated upload of the results to the CAST Highlight platform. You can easily use your defined pipeline variables in the Docker command with the $(syntax), mainly for the upload part (serverUrl, companyId, applicationId, user token).
-v $(Build.SourcesDirectory):/sourceDir -v $(Agent.TempDirectory):/workingDir casthighlight/cli:latest --sourceDir sourceDir --workingDir workingDir --serverUrl $(highlightInstanceUrl) --companyId $(highlightCompanyId) --applicationId $(highlightApplicationId) --tokenAuth $(highlightUserOAuthToken)
As I was not personally familiar with Docker – and if you’re in the same situation – I’d recommend you start with a simple CLI example (e.g. --help). It will help you progress step by step.Finally, save your pipeline and run it!
For reference only. For the complete details please refer the original article
https://doc.casthighlight.com/tutorial-run-docker-scan-image-azure-devops-pipelines/
https://doc.casthighlight.com/tutorial-run-docker-scan-image-azure-devops-pipelines/
Comments