-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Jenkinsfile that pushes to Pypi and DockerHub
- Loading branch information
1 parent
d38e475
commit a533072
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
venv | ||
__pycache__ | ||
|
||
.eggs | ||
*.egg-info | ||
dist | ||
build | ||
AUTHORS | ||
ChangeLog | ||
|
||
.DS_Store | ||
|
||
doc/_* | ||
|
||
.idea | ||
|
||
*.xlsx | ||
|
||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM python:3.7.2 | ||
|
||
LABEL maintainer="kaden@vermilion.tech" | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY requirements.txt . | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT [ "python", "-m", "realvalidation" ] | ||
|
||
CMD [ "--help" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
pipeline { | ||
agent any | ||
|
||
environment { | ||
COMMIT_MESSAGE = """${sh( | ||
returnStdout: true, | ||
script: "git --no-pager log --format='medium' -1 ${GIT_COMMIT}" | ||
)}""" | ||
COMMIT_HASH = """${sh( | ||
returnStdout: true, | ||
script: "git describe --always" | ||
)}""" | ||
|
||
PYTHON_VERSION = '3.7.2' | ||
|
||
PYPIRC_CREDENTIALS = "pypirc-kaden-vt" | ||
|
||
DOCKER_REPO = "kadenlnelson/realvalidation" | ||
DOCKER_CREDENTIALS = "docker-hub-kadenlnelson" | ||
} | ||
|
||
stages { | ||
stage('Notify Slack') { | ||
steps { | ||
slackSend(color: '#000000', message: "Build Started - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)\n```${env.COMMIT_MESSAGE}```") | ||
} | ||
} | ||
|
||
stage('Build & Push Python Distributions') { | ||
agent { docker { image "python:${PYTHON_VERSION}" } } | ||
steps { | ||
sh 'pip install -r requirements.txt' | ||
sh 'rm -rf dist' | ||
sh 'python setup.py sdist bdist_wheel' | ||
script { | ||
SEMVER = """${sh( | ||
returnStdout: true, | ||
script: "python setup.py --version" | ||
)}""" | ||
} | ||
withCredentials([file(credentialsId: "${PYPIRC_CREDENTIALS}", variable: 'PYPIRC')]) { | ||
sh 'twine upload --config-file $PYPIRC dist/*' | ||
} | ||
slackSend (color: '#ffde57', message: "PyPi Package Pushed - https://pypi.org/project/realvalidation/\n```\nTry it out!\n\npip install realvalidation==${SEMVER}```") | ||
} | ||
} | ||
|
||
stage('Build & Push Docker Image') { | ||
agent { docker { image 'docker:18.09.2' } } | ||
steps { | ||
script { | ||
def branchName = "${GIT_BRANCH}".replace('/', '_') | ||
def image = docker.build("${DOCKER_REPO}") | ||
|
||
docker.withRegistry('', "${DOCKER_CREDENTIALS}") { | ||
image.push(branchName) | ||
image.push("${SEMVER}") | ||
} | ||
} | ||
|
||
slackSend (color: '#0db7ed', message: "Docker Image Built & Pushed - https://hub.docker.com/r/kadenlnelson/realvalidation/tags\n```\nTry it out!\n\ndocker run --rm ${DOCKER_REPO}:${SEMVER}```") | ||
} | ||
} | ||
} | ||
|
||
post { | ||
failure { | ||
slackSend (color: '#FF0000', message: "Build Failed! - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)") | ||
} | ||
|
||
success { | ||
slackSend (color: '#00FF00', message: "Success! - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters