1+ # Step 5 - Ensure Backward compatibility
2+ variable "tenancy_ocid" {}
3+ variable "user_ocid" {}
4+ variable "fingerprint" {}
5+ variable "private_key_path" {}
6+ variable "compartment_ocid" {}
7+ variable "region" {}
8+ variable "default_branch" {}
9+ variable "baseVersion" {
10+ default = " master"
11+ }
12+ variable "baseVersion_fork" {
13+ default = " main"
14+ }
15+ variable "targetVersion" {
16+ default = " <target>"
17+ }
18+ variable "connection_access_token" {
19+ default = " "
20+ }
21+
22+ provider "oci" {
23+ version = " 5.13.0"
24+ region = var. region
25+ tenancy_ocid = var. tenancy_ocid
26+ user_ocid = var. user_ocid
27+ fingerprint = var. fingerprint
28+ private_key_path = var. private_key_path
29+ }
30+
31+ resource "random_string" "topicname" {
32+ length = 10
33+ special = false
34+ }
35+
36+ resource "random_string" "projectname" {
37+ length = 10
38+ special = false
39+ }
40+
41+ resource "oci_ons_notification_topic" "test_notification_topic" {
42+ # Required
43+ compartment_id = var. compartment_ocid
44+ name = join (" " , [" A" , random_string . topicname . result ])
45+ }
46+
47+ # Create Project
48+ resource "oci_devops_project" "test_project" {
49+ # Required
50+ compartment_id = var. compartment_ocid
51+ name = join (" " , [" A" , random_string . projectname . result ])
52+ notification_config {
53+ # Required
54+ topic_id = oci_ons_notification_topic. test_notification_topic . id
55+ }
56+ }
57+
58+ resource "oci_devops_connection" "test_connection" {
59+ # Required
60+ connection_type = " GITHUB_ACCESS_TOKEN"
61+ project_id = oci_devops_project. test_project . id
62+ access_token = var. connection_access_token
63+
64+ # Optional
65+ description = " description"
66+ display_name = " display_name"
67+ }
68+
69+ # Create HOSTED repository
170resource "oci_devops_repository" "test_repository" {
271 # Required
372 name = " repositoryName"
473 project_id = oci_devops_project. test_project . id
74+ repository_type = " HOSTED"
575
676 # Optional
7- default_branch = " defaultBranch "
77+ default_branch = var . default_branch
878 description = " description"
9- repository_type = " HOSTED"
1079}
1180
81+ # Create new branch in HOSTED repository
82+ resource "oci_devops_repository_ref" "test_repository_ref" {
83+ commit_id = lookup (data. oci_devops_repository_commits . test_repository_commits . repository_commit_collection [0 ]. items [0 ], " commit_id" )
84+ ref_name = " <refName>"
85+ ref_type = " BRANCH"
86+ repository_id = oci_devops_repository. test_repository . id
87+
88+ lifecycle {
89+ ignore_changes = [
90+ defined_tags ,
91+ freeform_tags
92+ ]
93+ }
94+ }
95+
96+ # Create MIRRORED repository
1297resource "oci_devops_repository" "test_mirrored_repository" {
1398 # Required
1499 name = " repositoryMirroredName"
15100 project_id = oci_devops_project. test_project . id
101+ repository_type = " MIRRORED"
16102
17103 # Optional
18- default_branch = " defaultBranch "
104+ default_branch = var . default_branch
19105 description = " description"
20- repository_type = " MIRRORED"
21106 mirror_repository_config {
22107 connector_id = oci_devops_connection. test_connection . id
23- repository_url = " https://github.com/Maxrovr/hello-dev "
108+ repository_url = " <repository_url> "
24109 trigger_schedule {
25110 schedule_type = " NONE"
26111 }
27112 }
28113}
29114
115+ # Mirror/Sync MIRRORED repository
30116resource "oci_devops_repository_mirror" "test_repository_mirror" {
31117 # Required
32118 repository_id = oci_devops_repository. test_mirrored_repository . id
33119}
34120
35- resource "oci_devops_repository_ref" "test_repository_ref" {
36- commit_id = " commitId"
37- ref_name = " refName"
38- ref_type = " BRANCH"
121+ # Retrieve List of commits in HOSTED repository
122+ data "oci_devops_repository_commits" "test_repository_commits" {
123+ # Required
39124 repository_id = oci_devops_repository. test_repository . id
40125}
41126
42- resource "oci_devops_repository_ref" "test_repository_ref" {
43- object_id = " object_id "
44- ref_name = " refName "
45- ref_type = " TAG "
127+ # ListCommitsDiff
128+ data "oci_devops_repository_diffs" "test_repository_diff" {
129+ # Required
130+ base_version = var . baseVersion_fork
46131 repository_id = oci_devops_repository. test_repository . id
132+ target_version = var. targetVersion
133+
134+ # Optional
135+ is_comparison_from_merge_base = false
47136}
137+
138+ output "commit_diffs" {
139+ value = data. oci_devops_repository_diffs . test_repository_diff
140+ }
0 commit comments