File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,28 +15,40 @@ steps:
1515 args : ["-c", "pip3 install -r requirements.txt && python3 -m pytest"]
1616
1717 - name : ' gcr.io/cloud-builders/docker'
18- id : build-auto-scan-if-master
18+ id : generate-image-name
1919 entrypoint : ' bash'
2020 dir : services/auto-scan
2121 args :
22- - ' -c'
23- - |
24- if [[ "$BRANCH_NAME" == "master" ]]
25- then
26- docker build -t gcr.io/$PROJECT_ID/services/autoscan:$BRANCH_NAME-$SHORT_SHA .
27- else
28- exit 0
29- fi
22+ - ' -c'
23+ - |
24+ echo "gcr.io/$PROJECT_ID/services/autoscan:$BRANCH_NAME-$SHORT_SHA-$(date +%s)" > /workspace/imagename
3025
3126 - name : ' gcr.io/cloud-builders/docker'
32- id : push-auto-scan -if-master
27+ id : build -if-master
3328 entrypoint : ' bash'
29+ dir : services/auto-scan
30+ args :
31+ - ' -c'
32+ - |
33+ if [[ "$BRANCH_NAME" == "master" ]]
34+ then
35+ image=$(cat /workspace/imagename)
36+ docker build -t $image .
37+ else
38+ exit 0
39+ fi
40+
41+ - name : ' gcr.io/cloud-builders/docker'
42+ id : push-if-master
43+ entrypoint : ' bash'
44+ dir : services/auto-scan
3445 args :
35- - ' -c'
36- - |
37- if [[ "$BRANCH_NAME" == "master" ]]
38- then
39- docker push gcr.io/$PROJECT_ID/services/autoscan:$BRANCH_NAME-$SHORT_SHA
40- else
41- exit 0
42- fi
46+ - ' -c'
47+ - |
48+ if [[ "$BRANCH_NAME" == "master" ]]
49+ then
50+ image=$(cat /workspace/imagename)
51+ docker push $image
52+ else
53+ exit 0
54+ fi
You can’t perform that action at this time.
0 commit comments