Skip to content

Commit dd44a0a

Browse files
committed
image copy support
1 parent e4e2ca3 commit dd44a0a

File tree

9 files changed

+63
-1
lines changed

9 files changed

+63
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The Xpresso Plugin executes sanity job(s) registered in Cisco Xpresso(s) as a Je
55
## Table Of Content
66
- [Installation](guide/installation.md)
77
- [Quick Start](guide/quick_start.md)
8+
- [Dynamic Image Copy](image.md)
89

910
## Related pyATS Plugins
1011
- [pyATS Jenkins Project Plugin](https://github.com/CiscoTestAutomation/jenkins_project_plugin)

guide/README.md

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
## User Guide Table Of Content
22
- [Installation](installation.md)
3-
- [Quick Start](quick_start.md)
3+
- [Quick Start](quick_start.md)
4+
- [Dynamic Image Copy](image.md)
83.8 KB
Loading
24.4 KB
Loading
66.8 KB
Loading
121 KB
Loading
28.5 KB
Loading
74.7 KB
Loading

guide/image.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Support QA image copy dynamically
2+
3+
This section provides an example that images are automatically copied from a known location where nightly builds are done to a given location that is needed by the sanity that is being executed by XPRESSO on Jenkins. There are many ways to achieve this on Jenkins, users can use the below mechanism template to customize their own solutions.
4+
5+
![](assets/images/image_intro.png)
6+
7+
## Step 1: create a project with parameters
8+
* create a free style project (similar way if user use Pipline or Build Flow project)
9+
* configure 3 'String' parameters:
10+
- IMAGE_PATH (source image nightly build folder, for example Cisco automount locaiton)
11+
- IMAGE_NAME (image name, support regx pattern)
12+
- TARGET (image copied destination, can be another Cisco automount location or typical local Jenkins workspace)
13+
14+
![](assets/images/image_parameter.png)
15+
16+
## Step 2 schedule the run:
17+
Configure the job to run each day at 2 AM. User can set his own schedule by using cron syntax.
18+
19+
![](assets/images/image_schedule.png)
20+
21+
22+
## Step 3 add a build step to copy the image:
23+
There are many ways to copy image files from one location to another in Jenkins, most need special setup or some third party plugins, for example 'file operations': https://wiki.jenkins.io/display/JENKINS/File+Operations+Plugin
24+
25+
![](assets/images/image_fileoperation.png)
26+
27+
In case the user has Cisco EngIT managed Jenkins, which installing plugins and configuring system settings can be limitations. Here we use native Jenkins shell command to achieve the requirements. Add build step: Execute shell
28+
29+
![](assets/images/image_copystep.png)
30+
31+
Check the comments in the following code, and customize the commands as users' requirements.
32+
33+
# find the latest image folder created from the nightly builds
34+
LATEST_IMAGE_FOLDER=$(ls -td $IMAGE_PATH/*/ | head -1)
35+
36+
# build the latest image source path
37+
LEN=${#LATEST_IMAGE_FOLDER}
38+
LATEST_IMAGE_FOLDER=${LATEST_IMAGE_FOLDER::LEN-1}
39+
FINAL_IMAGE_PATH=$LATEST_IMAGE_FOLDER/$IMAGE_NAME
40+
41+
# make sure there is a target image we want to copy and test, sometimes if build failed, empty folder created
42+
if ls $FINAL_IMAGE_PATH 1> /dev/null 2>&1; then
43+
echo "files do exist"
44+
# copy the image from source to destination defined in $TARGET, rename it to a unique known to the next build step
45+
# if want to copy the image to local Jenkins. instead of $TARGET, use $WORKSPACE
46+
cp $FINAL_IMAGE_PATH $TARGET/cat9k_latest_$BUILD_ID.SSA.bin
47+
else
48+
# no image found, exit the curent build
49+
echo "Image directory is empty! Aborting the build, and see you tomorrow :)"
50+
exit 1
51+
fi
52+
53+
## Step 4 trigger the xpresso build using the image:
54+
After the previous step, the image file should be copied to the location the executor Jenkins be able to access.
55+
56+
Assume the job have already properly registered on the Xpresso already.
57+
58+
Add build step: Execute Xpresso Job. Specify the image info with Json format in the "clean info" section.
59+
60+
![](assets/images/image_xpresso_run.png)

0 commit comments

Comments
 (0)