-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitbucket-pipelines.yml
87 lines (86 loc) · 3.17 KB
/
bitbucket-pipelines.yml
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
definitions:
steps:
- step: &build-docker-image
name: 'Build Docker Image'
script:
- IMAGE_NAME=cyclonedx-bitbucket-pipe
- docker build --build-arg ARCH=amd64 --tag "${IMAGE_NAME}:local" .
- docker save "${IMAGE_NAME}:local" --output "${IMAGE_NAME}.tar"
services:
- docker
caches:
- docker
artifacts:
- "*.tar"
- step: &build-and-test
name: 'Build and Test'
image: bats/bats:1.9.0
script:
- echo "Running tests...."
- test/gen_sbom.bats --timing --show-output-of-passing-tests --verbose-run
- step: &shell-check
name: 'Shell Lint'
image: koalaman/shellcheck-alpine:v0.9.0
script:
- echo "Linting shell scripts"
- shellcheck -x *.sh **/*.bats
- step: &docker-lint
name: 'Docker Lint'
image: hadolint/hadolint:v2.12.0-alpine
script:
- echo "Linting Dockerfile(s)"
- hadolint Dockerfile
- step: &markdown-lint
name: 'Markdown Lint'
image: markdownlint/markdownlint:0.13.0
script:
- echo "Linting Markdown Files"
- mdl *.md || echo "Potential mdlint issues found..."
pipelines:
default:
- parallel:
- step: *build-and-test
- step: *shell-check
- step: *docker-lint
- step: *markdown-lint
- step: *build-docker-image
custom:
push to Dockerhub (dev):
- step: *build-docker-image
- step:
name: 'Publish Dev Docker Image'
deployment: Development
script:
- echo ${DOCKERHUB_PASSWORD} | docker login --username "${DOCKERHUB_USERNAME}" --password-stdin
- IMAGE_NAME=cyclonedx-bitbucket-pipe
- docker load --input "${IMAGE_NAME}.tar"
- docker tag "${IMAGE_NAME}:local" "${DOCKERHUB_NAMESPACE}/${IMAGE_NAME}:${DEV_VERSION}-${BITBUCKET_BUILD_NUMBER}"
- docker push "${DOCKERHUB_NAMESPACE}/${IMAGE_NAME}:${DEV_VERSION}-${BITBUCKET_BUILD_NUMBER}"
services:
- docker
Prod Release:
- variables:
- name: PRODUCTION_VERSION
- step: *build-docker-image
- stage:
name: Deploy to Prod
deployment: Production
steps:
- step:
name: 'Publish Prod Docker Image'
script:
- IMAGE_NAME=cyclonedx-bitbucket-pipe
- echo ${DOCKERHUB_PASSWORD} | docker login --username "${DOCKERHUB_USERNAME}" --password-stdin
- docker load --input "${IMAGE_NAME}.tar"
- docker tag "${IMAGE_NAME}:local" "${DOCKERHUB_NAMESPACE}/${IMAGE_NAME}:${PRODUCTION_VERSION}"
- docker push "${DOCKERHUB_NAMESPACE}/${IMAGE_NAME}:${PRODUCTION_VERSION}"
services:
- docker
caches:
- docker
- step:
name: tag branch
image: alpine/git:1.0.26
script:
- git tag -a "v${PRODUCTION_VERSION}" -m "release version ${PRODUCTION_VERSION}"
- git push origin "v${PRODUCTION_VERSION}"