Merge d0bd96b94c into 128e9ba59f
這個提交存在於:
當前提交
90be6ec00c
共有 2 個檔案被更改,包括 84 行新增 和 1 行删除
81
Jenkinsfile
vendored
一般檔案
81
Jenkinsfile
vendored
一般檔案
|
|
@ -0,0 +1,81 @@
|
|||
pipeline {
|
||||
agent none
|
||||
stages {
|
||||
|
||||
stage('FindHTTPCalls') {
|
||||
agent {
|
||||
docker {
|
||||
image 'alpine:3.14'
|
||||
}
|
||||
}
|
||||
environment {
|
||||
HTTPCALLS = """${sh(
|
||||
returnStdout: true,
|
||||
script: 'find ./sources -path "*.py" -exec grep -H -e "http://" {} \\;'
|
||||
)}"""
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
if (env.HTTPCALLS?.trim()) {
|
||||
currentBuild.result = 'ABORTED'
|
||||
error("Aborting the build for http calls.")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
agent {
|
||||
docker {
|
||||
image 'python:2-alpine'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'python -m py_compile sources/add2vals.py sources/calc.py'
|
||||
stash(name: 'compiled-results', includes: 'sources/*.py*')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('Test') {
|
||||
agent {
|
||||
docker {
|
||||
image 'qnib/pytest'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'py.test --junit-xml test-reports/results.xml sources/test_calc.py'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
junit 'test-reports/results.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('Deliver') {
|
||||
agent any
|
||||
environment {
|
||||
VOLUME = '$(pwd)/sources:/src'
|
||||
IMAGE = 'cdrx/pyinstaller-linux:python2'
|
||||
}
|
||||
steps {
|
||||
dir(path: env.BUILD_ID) {
|
||||
unstash(name: 'compiled-results')
|
||||
sh "docker run --rm -v ${VOLUME} ${IMAGE} 'pyinstaller -F add2vals.py'"
|
||||
}
|
||||
}
|
||||
post {
|
||||
success {
|
||||
archiveArtifacts "${env.BUILD_ID}/sources/dist/add2vals"
|
||||
sh "docker run --rm -v ${VOLUME} ${IMAGE} 'rm -rf build dist'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,11 +5,13 @@ the calc.py library's 'add2' function.
|
|||
|
||||
import sys
|
||||
import calc
|
||||
import requests
|
||||
|
||||
argnumbers = len(sys.argv) - 1
|
||||
r =requests.get('https://xkcd.com/1906/')
|
||||
|
||||
if argnumbers == 2 :
|
||||
print("")
|
||||
# print("")
|
||||
print("The result is " + str(calc.add2(str(sys.argv[1]), str(sys.argv[2]))))
|
||||
print("")
|
||||
sys.exit(0)
|
||||
|
|
|
|||
載入中…
新增問題並參考