feat: sample of force use specific jenkins agent (#2)
Co-authored-by: TzuWei <tzuwei.huang@ironyun.com> Reviewed-on: #2 Reviewed-by: joy <joy224961632@gmail.com> Co-authored-by: tzuwei-huang <htw41043223@gmail.com> Co-committed-by: tzuwei-huang <htw41043223@gmail.com>
This commit is contained in:
parent
f639c0b96a
commit
df1d6fe091
2
.gitignore
vendored
2
.gitignore
vendored
@ -124,4 +124,4 @@ Temporary Items
|
||||
Report
|
||||
test-reports
|
||||
.idea
|
||||
.env
|
||||
.env
|
||||
|
||||
@ -6,15 +6,14 @@ ENV DISPLAY=:99
|
||||
RUN apt-get -y update
|
||||
RUN apt-get install -y p7zip-full
|
||||
|
||||
RUN useradd -ms /bin/bash -u 1000 jenkins && \
|
||||
echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
RUN useradd -ms /bin/bash -u 1000 jenkins && echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip3 install --upgrade pip && \
|
||||
pip3 install --no-cache-dir -r requirements.txt && \
|
||||
pip3 install --no-cache-dir pytest
|
||||
RUN pip3 install --upgrade pip
|
||||
RUN pip3 install --no-cache-dir -r requirements.txt
|
||||
RUN pip3 install --no-cache-dir pytest
|
||||
|
||||
COPY . .
|
||||
|
||||
|
||||
59
Jenkinsfile
vendored
59
Jenkinsfile
vendored
@ -1,35 +1,38 @@
|
||||
properties([
|
||||
parameters([
|
||||
string(
|
||||
name: 'TEST_MARK',
|
||||
defaultValue: 'All',
|
||||
description: 'To filter test cases, default is All'
|
||||
)
|
||||
])
|
||||
parameters([
|
||||
string(
|
||||
name: 'TEST_MARK',
|
||||
defaultValue: 'All',
|
||||
description: 'To filter test cases, default is All'
|
||||
)
|
||||
])
|
||||
])
|
||||
|
||||
node {
|
||||
stage('Setup Environment') {
|
||||
cleanWs()
|
||||
checkout scm
|
||||
node('ccis') {
|
||||
stage('Setup Environment') {
|
||||
cleanWs()
|
||||
checkout scm
|
||||
|
||||
def image = docker.build('pytest-test', '.')
|
||||
env.IMAGE_ID = image.id
|
||||
def image = docker.build('pytest-test', '.')
|
||||
env.IMAGE_ID = image.id
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
docker.image(env.IMAGE_ID).inside("--user jenkins --shm-size=1g") {
|
||||
sh 'mkdir -p Report test-reports || true'
|
||||
sh 'if [ -f Report_Http.zip ]; then rm Report_Http.zip; fi'
|
||||
|
||||
withEnv(["TEST_MARK=${params.TEST_MARK}"]) {
|
||||
sh 'python3 exec.py'
|
||||
}
|
||||
|
||||
sh '7z a -tzip Report_Http.zip Report'
|
||||
archiveArtifacts artifacts: 'Report_Http.zip', followSymlinks: false
|
||||
archiveArtifacts artifacts: 'test-reports/**', followSymlinks: false
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
docker.image(env.IMAGE_ID).inside("--user jenkins --shm-size=1g") {
|
||||
withEnv(["TEST_MARK=${params.TEST_MARK}"]) {
|
||||
sh 'python3 exec.py'
|
||||
sh '7z a -tzip Report_Http.zip 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
|
||||
}
|
||||
stage('Prepare Report') {
|
||||
junit testResults: 'test-reports/junit-report.xml', allowEmptyResults: true
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user