forked from julz0815/ADO-Veracode-Pipeline-Scan-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin-update.sh
executable file
·117 lines (97 loc) · 5.28 KB
/
plugin-update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#/bin/bash
#./plugin-update.sh ADO_ORG ADO_TOKEN justBuildIt
cd new_pipeline_scanner
curl -sSO https://downloads.veracode.com/securityscan/pipeline-scan-LATEST.zip
unzip -o pipeline-scan-LATEST.zip
cd ..
version_new=$(java -jar new_pipeline_scanner/pipeline-scan.jar --version)
version_old=$(java -jar pipelinescan/pipeline-scan-LATEST/pipeline-scan.jar --version)
echo "Version New: " $version_new
echo "Version Old: " $version_old
if [ "$version_new" != "$version_old" ]; then
echo "New version was deployed, an update is required"
#find the actual plugin version number
current_plugin_version=$(cat vss-extension.json | grep "version" | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | cut -d. -f3)
echo "Current Plugin Version: " $current_plugin_version
#set new plugin version
new_plugin_version=$((current_plugin_version +1))
echo "New Plugin Version " $new_plugin_version
#patch the file with new version
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Patching ./vss-extension.json"
sed -i "" "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./vss-extension.json"
echo "Patching ./pipelinescan/task.json"
sed -i "" "s/\"Patch\":.*/\"Patch\": $new_plugin_version/g" "./pipelinescan/task.json"
echo "Patching ./pipelinescan/package.json"
sed -i "" "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./pipelinescan/package.json"
echo "Patching ./package.json"
sed -i "" "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./package.json"
else
echo "Patching ./vss-extension.json"
sed -i "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./vss-extension.json"
echo "Patching ./pipelinescan/task.json"
sed -i "s/\"Patch\":.*/\"Patch\": $new_plugin_version/g" "./pipelinescan/task.json"
echo "Patching ./pipelinescan/package.json"
sed -i "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./pipelinescan/package.json"
echo "Patching ./package.json"
sed -i "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./package.json"
fi
#copy pipeline-scan jar to correct folder
mv new_pipeline_scanner/pipeline-scan.jar pipelinescan/pipeline-scan-LATEST/
rm -rf new_pipeline_scanner/pipeline-scan-LATEST.zip
rm -rf new_pipeline_scanner/README.md
#build the plugin
cd pipelinescan
tsc
cd ..
npm run build
copy_file=$(mv ./JulianTotzek-Hallhuber.VeracodePipelineScan-0.1.$new_plugin_version.vsix ./builds)
# Publish to market place
tfx extension publish --vsix "builds/JulianTotzek-Hallhuber.VeracodePipelineScan-0.1.$new_plugin_version.vsix" --share-with $1 --token $2
else
echo "No new version of the pipeline scan found! Checking if plugin should be updated."
if [[ $3 == "justBuildIt" ]]; then
echo "Code was updated and the plugin will rebuild"
#find the actual plugin version number
current_plugin_version=$(cat vss-extension.json | grep "version" | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | cut -d. -f3)
echo "Current Plugin Version: " $current_plugin_version
#set new plugin version
new_plugin_version=$((current_plugin_version +1))
echo "New Plugin Version " $new_plugin_version
#patch the file with new version
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Patching ./vss-extension.json"
sed -i "" "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./vss-extension.json"
echo "Patching ./pipelinescan/task.json"
sed -i "" "s/\"Patch\":.*/\"Patch\": $new_plugin_version/g" "./pipelinescan/task.json"
echo "Patching ./pipelinescan/package.json"
sed -i "" "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./pipelinescan/package.json"
echo "Patching ./package.json"
sed -i "" "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./package.json"
else
echo "Patching ./vss-extension.json"
sed -i "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./vss-extension.json"
echo "Patching ./pipelinescan/task.json"
sed -i "s/\"Patch\":.*/\"Patch\": $new_plugin_version/g" "./pipelinescan/task.json"
echo "Patching ./pipelinescan/package.json"
sed -i "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./pipelinescan/package.json"
echo "Patching ./package.json"
sed -i "s/\"version\":.*/\"version\": \"0.1.$new_plugin_version\",/g" "./package.json"
fi
#build the plugin
cd pipelinescan
tsc
cd ..
npm run build
copy_file=$(mv ./JulianTotzek-Hallhuber.VeracodePipelineScan-0.1.$new_plugin_version.vsix ./builds)
# Publish to market place
tfx extension publish --vsix "builds/JulianTotzek-Hallhuber.VeracodePipelineScan-0.1.$new_plugin_version.vsix" --share-with $1 --token $2
else
echo "No code update done, no plugin update needed"
fi
#delete newly downloaded pipeline-scan jar
mv new_pipeline_scanner/pipeline-scan.jar pipelinescan/pipeline-scan-LATEST/
rm -rf new_pipeline_scanner/pipeline-scan-LATEST.zip
rm -rf new_pipeline_scanner/README.md
exit 1
fi;