This topic describes AWS Codebuild’s integration with the Unified Agent.
AWS CodeBuild is a fully managed build service that compiles source code, runs tests, and produces software packages that are ready to deploy. With CodeBuild, you do not need to provision, manage, and scale your own build servers. CodeBuild scales continuously and processes multiple builds concurrently, so your builds are not left waiting in a queue.
AWS CodeBuild integration with Mend allows customers to automate the scanning of any project using AWS CodeBuild, tapping into the continuous integration pipeline. The integration allows customers to automatically fail builds in case of an organizational compliance or security policy violation.
You can start by using prepackaged build environments, or you can create custom build environments that use your own build tools. With CodeBuild, you are charged by the minute for the compute resources you use. For further information, see here.
NOTE: It is advised to use the curl command only once a week to download the latest version of the Unified Agent for performance reasons and not as part of every build. You can do this using a scheduler task, such as cron.
Add the following commands to the post-build phase: bash wss_agent.sh -apiKey $ws_api_key -project my-project -d . -wss.url https://<environment>.Mendsoftware.com/agent where <environment> corresponds to saas/app/saas-eu/app-eu These commands will run the script wss_agent.sh. The script will download the latest version of Mend Unified Agent jar file and its config file to your AWS CodeBuild server and execute it with the regular command-line arguments of Unified Agent. Determine the name of the Mend project.
The buildspec.yml file should have the below structure:
Open the CodeBuild service from the Developer Tools services category.
Click Create build project or choose one of your existing projects.
Make sure that the Build specification option uses the default buildspec.yml file.
In the Advanced Settings section, add an Environment variable with the name ws_api_key and the value of your WSS API Key.
Click Continue and then Save or Save and Build to directly build after the save.
Following a successful build process, your Mend service will be updated with the details of your project, and a build of your project (zipped or not) will be placed inside the S3 bucket you have selected in your project's settings.
You can see your build details, by choosing the Build run from the Build history list. Mend's logging information will be listed under Build logs. The scanning command and its output will appear in the POST_BUILD phase in the build log.
After the build completes with a Mend scan, you can review the scanning results in your Mend organization under the relevant project.
In case of a Mend scanning error, the scanning step returns an error code. See the return codes below. Returning an exit code other than success results in a failure of the build step.
The exit codes Mend returns in the Bash command language should be treated as 'x' modulo 256:
Exit code 0 is equivalent to code 0 (0 mod 256 = 0)
Exit code -1 is equivalent to code 255 (-1 mod 256 = 255)
Exit code -2 is equivalent to code 254 (-2 mod 256 = 254)
Exit code -3 is equivalent to code 253 (-3 mod 256 = 253)
Exit code -4 is equivalent to code 252 (-4 mod 256 = 252)