feat: jenkinsfile
This commit is contained in:
parent
e41b60f964
commit
118aefe653
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM python:3.13.3-bullseye
|
||||
LABEL authors="tzu-weihuang"
|
||||
|
||||
RUN apt-get update -y && \
|
||||
apt-get install -y --no-install-recommends p7zip-full && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN useradd -ms /bin/bash -u 1000 jenkins
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip3 install --upgrade pip && \
|
||||
pip3 install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
|
||||
USER jenkins
|
||||
CMD ["bash"]
|
||||
36
Jenkinsfile
vendored
Normal file
36
Jenkinsfile
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
properties([
|
||||
parameters([
|
||||
string(
|
||||
name: 'TEST_MARK',
|
||||
defaultValue: 'All',
|
||||
description: 'To filter test cases, default is All'
|
||||
)
|
||||
])
|
||||
])
|
||||
|
||||
node {
|
||||
stage('Setup Environment') {
|
||||
def tag = "pytest-test:${env.BUILD_TAG}"
|
||||
def image = docker.build(tag, '.')
|
||||
env.IMAGE_NAME = tag
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
docker.image(env.IMAGE_NAME).inside("--user jenkins --shm-size=1g") {
|
||||
withEnv(["TEST_MARK=${params.TEST_MARK}"]) {
|
||||
sh 'python3 exec.py'
|
||||
}
|
||||
|
||||
sh 'mkdir -p Report test-reports || true'
|
||||
sh 'rm -f Report_Http.zip || true'
|
||||
zip zipFile: 'Report_Http.zip', archive: false, dir: 'Report'
|
||||
|
||||
archiveArtifacts artifacts: 'Report_Http.zip', followSymlinks: false
|
||||
archiveArtifacts artifacts: 'test-reports/**', followSymlinks: false
|
||||
}
|
||||
}
|
||||
|
||||
stage('Prepare Report') {
|
||||
junit testResults: 'test-reports/junit-report.xml', allowEmptyResults: true
|
||||
}
|
||||
}
|
||||
10
requirements.txt
Normal file
10
requirements.txt
Normal file
@ -0,0 +1,10 @@
|
||||
iniconfig==2.1.0
|
||||
jinja2==3.1.6
|
||||
markupsafe==3.0.2
|
||||
packaging==25.0
|
||||
pluggy==1.6.0
|
||||
pygments==2.19.2
|
||||
pytest==8.4.1
|
||||
pytest-html==4.1.1
|
||||
pytest-metadata==3.1.1
|
||||
python-dotenv==1.1.1
|
||||
Loading…
x
Reference in New Issue
Block a user