|
| 1 | + |
| 2 | +## Sample illustration to user OCI DevOps Build pipeline's predefined system variables. |
| 3 | + |
| 4 | + |
| 5 | +## Predefined System Variables (of OCI Build pipeline stage) |
| 6 | + |
| 7 | +DevOps provides a set of predefined system variables with default values that you can use like environment variables in the build specification. These values are available within DevOps managed build stages and can expose to other stages via an explicit export of the variables. |
| 8 | +You need to export these values with another variable name which is following below patters. |
| 9 | + |
| 10 | +```markdown |
| 11 | +Parameter name can only consist of ASCII letter, digit or '_' (underscore) characters and not start with an oci (case-insensitive) prefix |
| 12 | +``` |
| 13 | + |
| 14 | +System Variables | Description | |
| 15 | +--- | --- | |
| 16 | +OCI_STAGE_ID | The OCID of the current stage. | |
| 17 | +OCI_PIPELINE_ID|The OCID of the current build pipeline.| |
| 18 | +OCI_BUILD_RUN_ID|The OCID of the current build run.| |
| 19 | +OCI_TRIGGER_COMMIT_HASH|Commit hash of the current trigger.| |
| 20 | +OCI_TRIGGER_SOURCE_BRANCH_NAME|Branch that triggers the build.| |
| 21 | +OCI_TRIGGER_SOURCE_URL|Repository URL that triggered the build| |
| 22 | +OCI_TRIGGER_EVENT_TYPE|Trigger that started the event.| |
| 23 | +OCI_PRIMARY_SOURCE_DIR|Default working directory of the build (primary source working directory).| |
| 24 | +OCI_WORKSPACE_DIR|Working directory value. Contains /workspace as the default value.| |
| 25 | +${OCI_WORKSPACE_DIR}/ "source-name"|Build source directory path."source-name" is the name of the build source given by the user while creating the Build stage.| |
| 26 | +OCI_BUILD_STAGE_NAME|Build stage name.| |
| 27 | +OCI_PRIMARY_SOURCE_NAME|Primary build source name.| |
| 28 | +OCI_PRIMARY_SOURCE_COMMIT_HASH|Primary build source commit hash used in the current build run.| |
| 29 | +OCI_PRIMARY_SOURCE_SOURCE_URL|Primary build source URL.| |
| 30 | +OCI_PRIMARY_SOURCE_SOURCE_BRANCH_NAME| Primary build source branch used in the current build run.| |
| 31 | + |
| 32 | +Reference - https://docs.oracle.com/en-us/iaas/Content/devops/using/build_specs.htm |
| 33 | + |
| 34 | +### Procedure to use the sample. |
| 35 | + |
| 36 | +- Clone the sample illustrations. |
| 37 | + ``` |
| 38 | + $ git init oci_build_parameters |
| 39 | + $ cd oci_imagescan_before_deploy |
| 40 | + $ git remote add origin <url to this git repo> |
| 41 | + $ git config core. sparsecheckout true |
| 42 | + $ echo "oci-build-examples/oci_build_parameters/*">>.git/info/sparse-checkout |
| 43 | + $ git pull --depth=1 origin main |
| 44 | +
|
| 45 | + ``` |
| 46 | +- Create a DevOps project - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_project.htm |
| 47 | +- Create an OCI Code repo - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_repo.htm |
| 48 | +- Create a build pipeline - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_buildpipeline.htm |
| 49 | +- Push these samples to the OCI Code repo. |
| 50 | +- Add a `Managed Build stage` to the build pipeline - https://docs.oracle.com/en-us/iaas/Content/devops/using/add_buildstage.htm |
| 51 | +- Run the build pipeline and verify the values. |
| 52 | +- You may use these values by defining an external repo (Github/Gitlab or Bitbucket) and validate the executions too - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_connection.htm |
| 53 | + |
| 54 | +Sample output |
| 55 | + |
| 56 | + ---- |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +#### Build Stage View (With a combination of OCI Code repo and Github.com repo) |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +#### Build logs for manual execution of build stage with OCI Code repo. |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +#### Build logs for an automated execution with a `Trigger`. |
| 71 | + |
| 72 | +- using Github Repo |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +- using OCI Code Repo |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +Contributors |
| 81 | +=========== |
| 82 | + |
| 83 | +- Author: Rahul M R. |
| 84 | +- Collaborators: NA |
| 85 | +- Last release: June 2022 |
| 86 | + |
| 87 | +### Back to examples. |
| 88 | +---- |
| 89 | + |
| 90 | +- 🍿 [Back to OCI DevOps Build sample](./../README.md) |
| 91 | +- 🏝️ [Back to OCI Devops sample](./../../README.md) |
| 92 | + |
0 commit comments