ci: Add Jenkins support, set Python version based on tags
This commit is contained in:
parent
fd1719a402
commit
e3cb29c454
56
Jenkinsfile
vendored
Normal file
56
Jenkinsfile
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
pipeline {
|
||||||
|
agent { node { label 'podman-aws-trivy' } }
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Prepare'){
|
||||||
|
// get tags
|
||||||
|
steps {
|
||||||
|
sh 'git fetch --tags ${GIT_URL} +refs/heads/${BRANCH_NAME}:refs/remotes/origin/${BRANCH_NAME}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build using rootless podman
|
||||||
|
stage('Build'){
|
||||||
|
steps {
|
||||||
|
sh 'make build'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Test'){
|
||||||
|
steps {
|
||||||
|
sh 'make test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan via trivy
|
||||||
|
stage('Scan'){
|
||||||
|
environment {
|
||||||
|
TRIVY_FORMAT = "template"
|
||||||
|
TRIVY_OUTPUT = "reports/trivy.html"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'mkdir -p reports'
|
||||||
|
sh 'make scan'
|
||||||
|
publishHTML target : [
|
||||||
|
allowMissing: true,
|
||||||
|
alwaysLinkToLastBuild: true,
|
||||||
|
keepAll: true,
|
||||||
|
reportDir: 'reports',
|
||||||
|
reportFiles: 'trivy.html',
|
||||||
|
reportName: 'TrivyScan',
|
||||||
|
reportTitles: 'TrivyScan'
|
||||||
|
]
|
||||||
|
|
||||||
|
// Scan again and fail on CRITICAL vulns
|
||||||
|
sh 'TRIVY_EXIT_CODE=1 TRIVY_SEVERITY=CRITICAL make scan'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push to ECR
|
||||||
|
stage('Push'){
|
||||||
|
steps {
|
||||||
|
sh 'make push'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
Makefile
19
Makefile
@ -12,23 +12,23 @@ else
|
|||||||
TRIVY_OPTS := client --remote ${TRIVY_REMOTE}
|
TRIVY_OPTS := client --remote ${TRIVY_REMOTE}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: test build test_upload upload all dev_setup docker
|
.PHONY: pytest build test_upload upload all dev_setup pybuild
|
||||||
|
|
||||||
all: test build
|
all: pybuild pytest
|
||||||
|
|
||||||
dev_setup:
|
dev_setup:
|
||||||
pip install -r requirements.txt --user
|
pip install -r dev-requirements.txt --user
|
||||||
|
|
||||||
test:
|
pytest:
|
||||||
flake8 --ignore=E501 cloudbender tests
|
flake8 --ignore=E501 cloudbender tests
|
||||||
TEST=True pytest --log-cli-level=DEBUG
|
TEST=True pytest --log-cli-level=DEBUG
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
|
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
|
||||||
|
|
||||||
build: $(PACKAGE_FILE)
|
pybuild:
|
||||||
|
# Set version in Python
|
||||||
$(PACKAGE_FILE):
|
sed -i cloudbender/__init__.py -e 's/__version__.*/__version__ = "$(TAG)"/'
|
||||||
python setup.py bdist_wheel --universal
|
python setup.py bdist_wheel --universal
|
||||||
|
|
||||||
test_upload: $(PACKAGE_FILE)
|
test_upload: $(PACKAGE_FILE)
|
||||||
@ -37,9 +37,12 @@ test_upload: $(PACKAGE_FILE)
|
|||||||
upload: $(PACKAGE_FILE)
|
upload: $(PACKAGE_FILE)
|
||||||
twine upload --repository-url https://upload.pypi.org/legacy/ dist/cloudbender-*.whl
|
twine upload --repository-url https://upload.pypi.org/legacy/ dist/cloudbender-*.whl
|
||||||
|
|
||||||
docker:
|
build:
|
||||||
podman build --rm --squash-all -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
|
podman build --rm --squash-all -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
|
||||||
|
|
||||||
|
test:
|
||||||
|
@echo "Not implemented (yet)"
|
||||||
|
|
||||||
push:
|
push:
|
||||||
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
|
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
|
||||||
podman tag $(REPOSITORY):latest $(REGISTRY)/$(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):latest
|
podman tag $(REPOSITORY):latest $(REGISTRY)/$(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):latest
|
||||||
|
@ -2,7 +2,7 @@ import logging
|
|||||||
|
|
||||||
__author__ = "Stefan Reimer"
|
__author__ = "Stefan Reimer"
|
||||||
__email__ = "stefan@zero-downtimet.net"
|
__email__ = "stefan@zero-downtimet.net"
|
||||||
__version__ = "0.10.2"
|
__version__ = "v0.10.3"
|
||||||
|
|
||||||
|
|
||||||
# Set up logging to ``/dev/null`` like a library is supposed to.
|
# Set up logging to ``/dev/null`` like a library is supposed to.
|
||||||
|
Loading…
Reference in New Issue
Block a user