|
| 1 | +#Integrate using dxi cli |
| 2 | + |
| 3 | + |
| 4 | +Now that you have installed and configured dxi, let us explore how we can integrate Delphix operations into workflows. |
| 5 | +We will be using a sample Jenkins Pipeline as an example. |
| 6 | + |
| 7 | +A Jenkins Pipeline Example 1 |
| 8 | +------------------- |
| 9 | + |
| 10 | +Our first example here is a Jenkins Declarative Pipeline that runs a set of automated tests. |
| 11 | +We want to integrate a VDB Snapshot operation and a VDB Rewind operation into this pipeline. |
| 12 | +This pipeline has 3 steps - |
| 13 | + |
| 14 | +- Pre-Test : Sets up the test environment |
| 15 | +- Automated Test1 : Runs a set of automation tests using a Delphix VDB named "vdb1" |
| 16 | +- Post-Test: Tears down the test environment |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +###Adding a Delphix Snapshot Operation |
| 21 | + |
| 22 | +Let's say, we want to modify this pipeline such that it take a snapshot of the VDB <span class="data_highlight">(vdb1)</span> in Delphix before the tests run. |
| 23 | + |
| 24 | + |
| 25 | +For this we can use the <span class="data_highlight">dxi snapshot</span> cli command as follows |
| 26 | + |
| 27 | +<div class="code_box_outer"> |
| 28 | + <div class="code_box_title"> |
| 29 | + <span class="code_title">Jenkins Pipeline Script</span> |
| 30 | + </div> |
| 31 | + <div> |
| 32 | + ```groovy hl_lines="6" |
| 33 | + pipeline { |
| 34 | + ... |
| 35 | + |
| 36 | + stage('VDB Snapshot') { |
| 37 | + steps { |
| 38 | + sh '/path/to/dxi database snapshot --name vdb1' |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + ... |
| 43 | + } |
| 44 | + ``` |
| 45 | + </div> |
| 46 | +</div> |
| 47 | + |
| 48 | +###Adding a Delphix Rewind Operation |
| 49 | + |
| 50 | +Next, we want to rewind the VDB <span class="data_highlight">(vdb1)</span> after the tests are run. |
| 51 | + |
| 52 | + |
| 53 | +For this we can use the <span class="data_highlight">dxi rewind</span> cli command as follows |
| 54 | + |
| 55 | +<div class="code_box_outer"> |
| 56 | + <div class="code_box_title"> |
| 57 | + <span class="code_title">Jenkins Pipeline Script</span> |
| 58 | + </div> |
| 59 | + <div> |
| 60 | + ```groovy hl_lines="6 15" |
| 61 | + pipeline { |
| 62 | + ... |
| 63 | + |
| 64 | + stage('VDB Snapshot') { |
| 65 | + steps { |
| 66 | + sh '/path/to/dxi database snapshot --name vdb1' |
| 67 | + } |
| 68 | + } |
| 69 | + ... |
| 70 | + stage('Automated Test 1') { |
| 71 | + ... |
| 72 | + } |
| 73 | + stage('Rewind VDB') { |
| 74 | + steps { |
| 75 | + sh '/path/to/dxi database rewind --name vdb1' |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + ``` |
| 80 | + </div> |
| 81 | +</div> |
| 82 | + |
| 83 | + |
| 84 | +###The Finished Pipeline |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +And you have now integrated Delphix Snapshot and Rewind operations into a Jenkins Pipeline. |
| 89 | + |
| 90 | +A Jenkins Pipeline Example 2 |
| 91 | +------------------- |
| 92 | + |
| 93 | +Our second example here is a Jenkins Declarative Pipeline that runs a series of automated tests, one after the other. |
| 94 | + |
| 95 | +We will use Delphix Self Service Containers (a group of VDBs) for this example as we want to create bookmarks between the different test executions. |
| 96 | +These bookmarks are references to specific points in time on our container's timeline and can |
| 97 | +be used to rewind our container to the timepoint referenced by the bookmark. |
| 98 | + |
| 99 | +This pipeline has 4 staps - |
| 100 | + |
| 101 | +- Pre-Test : Sets up the test environment |
| 102 | +- Automated Test1 : Runs first set of automation tests using a Delphix Container named <span class="data_highlight">container1</span> |
| 103 | +- Automated Test2 : Runs second set of automation tests using a Delphix Container named <span class="data_highlight">container1</span> |
| 104 | +- Post-Test: Tears down the test environment |
| 105 | + |
| 106 | +We will integrate the following Delphix Operations into this pipeline |
| 107 | + |
| 108 | +- Create a bookmark <span class="data_highlight">bmk-pre-test1</span> before Automated Test 1 |
| 109 | +- Create a bookmark <span class="data_highlight">bmk-pre-test2</span> before Automated Test 2 |
| 110 | +- Rewind the Container <span class="data-highlight">container1</span> to <span class="data_highlight">bmk-pre-test1</span> after Automation Test 2 |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +###Adding the Container Bookmark Operations |
| 115 | + |
| 116 | +We can use <span class="data_highlight">dxi bookmark</span> cli command as follows |
| 117 | + |
| 118 | +<div class="code_box_outer"> |
| 119 | + <div class="code_box_title"> |
| 120 | + <span class="code_title">Jenkins Pipeline Script</span> |
| 121 | + </div> |
| 122 | + <div> |
| 123 | + ```groovy hl_lines="6 7 15 16" |
| 124 | + pipeline { |
| 125 | + ... |
| 126 | + |
| 127 | + stage('Create bmk-pre-test1') { |
| 128 | + steps { |
| 129 | + sh '/path/to/dxi bookmark create |
| 130 | + --bookmarkname bmk-pre-test1 --containername container1' |
| 131 | + } |
| 132 | + } |
| 133 | + stage('Automated Test 2') { |
| 134 | + ... |
| 135 | + } |
| 136 | + stage('Create bmk-pre-test2') { |
| 137 | + steps { |
| 138 | + sh '/path/to/dxi bookmark create |
| 139 | + --bookmarkname bmk-pre-test2 --containername container1' |
| 140 | + } |
| 141 | + } |
| 142 | + ... |
| 143 | + } |
| 144 | + ``` |
| 145 | + </div> |
| 146 | +</div> |
| 147 | + |
| 148 | + |
| 149 | +###Adding the Container Restore Operations |
| 150 | + |
| 151 | +Next, we want to rewind/restore the container <span class="data_highlight">container1</span> to <span class="data_highlight">bmk-pre-test2>/span> |
| 152 | + |
| 153 | +For this we can use the <span class="data_highlight">dxi container</span> cli command as follows |
| 154 | + |
| 155 | +<div class="code_box_outer"> |
| 156 | + <div class="code_box_title"> |
| 157 | + <span class="code_title">Jenkins Pipeline Script</span> |
| 158 | + </div> |
| 159 | + <div> |
| 160 | + ```groovy hl_lines="21 22" |
| 161 | + pipeline { |
| 162 | + ... |
| 163 | + |
| 164 | + stage('Create bmk-pre-test1') { |
| 165 | + steps { |
| 166 | + sh '/path/to/dxi bookmark create |
| 167 | + --bookmarkname bmk-pre-test1 --containername container1' |
| 168 | + } |
| 169 | + } |
| 170 | + stage('Automated Test 2') { |
| 171 | + ... |
| 172 | + } |
| 173 | + stage('Create bmk-pre-test2') { |
| 174 | + steps { |
| 175 | + sh '/path/to/dxi bookmark create |
| 176 | + --bookmarkname bmk-pre-test2 --containername container1' |
| 177 | + } |
| 178 | + } |
| 179 | + stage('Restore to bmk-pre-test1') { |
| 180 | + steps { |
| 181 | + sh '/path/to/dxi container restore |
| 182 | + --bookmark_name bmk-pre-test2 --container_name container1' |
| 183 | + } |
| 184 | + } |
| 185 | + ... |
| 186 | + } |
| 187 | + ``` |
| 188 | + </div> |
| 189 | +</div> |
| 190 | + |
| 191 | + |
| 192 | +###The Finished Pipeline |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | +And you have now integrated Delphix Self Service Container Operations into a Jenkins Pipeline. |
| 197 | + |
| 198 | +##What's Next? |
| 199 | +As you have seen, with dxi, integration of Delphix Operations into your workflows take only a few minutes. |
| 200 | +For information on all supported Delphix operations, read our [References](/References/CLI_References/environment/index.html) section. |
0 commit comments