Mac docker deploys jenkins and runs automated code on jenkins

1, docker deployment jenkins

docker run -d -p 7000:8080 --name py42jenkins -u root -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker jenkins/jenkins:alpine

The deployment success diagram is as follows:

Command interpretation:

docker run: run container through image
– Name: the name of the startup container, such as culture py42jenkins
-u: Specify the startup user as root (you need to add root permission to the startup parameters, otherwise you will encounter the error of insufficient permission reported by startup jenkins)
-p: Port 8080 of the container is mapped to port 7000 of the virtual machine, and jenkins can be accessed by accessing port 7000 in the browser
-v: The purpose of directory mapping is to enable jenkins to execute the docker command of the host
-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker jenkins/jenkins:alpine
-d runs as a daemon thread. Without this parameter, close the command line and docker's jenkins will stop.

2, Check whether Jenkins starts

Execute command: docker ps -a
Status status: up indicates that the jenkins service has been started successfully, and the startup port 7000 is displayed

3, Access in browser

Via 7000 port
http://localhost:7000
Come to jenkins configuration interface

There are two ways to obtain a password:
The first is to: / var/jenkins_home/secrets/initialAdminPassword
The second is to view the container log command:
docker logs py42jenkins

Enter the administrator password to enter the next page: install plug-ins

Download some dependencies

After downloading, enter the create user interface:
User and password: admin



Click to start using jenkins

4, Create a new project on jenkins

1. Click new item

2,

Then wait for a moment:

After filling in the git address, it will display: unable to link

You need to fill in the user name and password of gitee warehouse.
Click Add:

Just select the account you just added.

Here you can choose the branch to pull. This is the master branch

The build step here is to select the shell script


Click Save:
Click build now:

Click #1, enter, and then click console output:

You can see the console output:

Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/py42
The recommended git tool is: NONE
using credential 7f32f8c0-75ad-4bfe-9789-cc1b0073b62f
Cloning the remote Git repository
Cloning repository https://gitee.com/wcystart/py42-api.git
 > git init /var/jenkins_home/workspace/py42 # timeout=10
Fetching upstream changes from https://gitee.com/wcystart/py42-api.git
 > git --version # timeout=10
 > git --version # 'git version 2.34.1'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --force --progress -- https://gitee.com/wcystart/py42-api.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://gitee.com/wcystart/py42-api.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision b3c4e866e6077a525da4e54d066ba94f45df32bf (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f b3c4e866e6077a525da4e54d066ba94f45df32bf # timeout=10
Commit message: "add dockerfile"
First time build. Skipping changelog.
[py42] $ /bin/sh -xe /tmp/jenkins9733523508438114569.sh
+ docker build -t py42test .
#1 [internal] load build definition from Dockerfile
#1 sha256:32a3869b9923db66deedbecc0323fd50db179465780ca289878f26b34dd15689
#1 transferring dockerfile:
#1 transferring dockerfile: 188B 0.0s done
#1 DONE 0.1s

#2 [internal] load .dockerignore
#2 sha256:24abdf63b561cdf1a4b5769c55d9b2145adb6e75598d530d5756e2b2cfaf46e0
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/python:3-alpine
#3 sha256:5cfd63f819a536533ccd33ab472b68bc5eaf5534980201cfb2f10a631818880f
#3 DONE 16.6s

#4 [1/4] FROM docker.io/library/python:3-alpine@sha256:dce56d40d885d2c8847aa2a278a29d50450c8e3d10f9d7ffeb2f38dcc1eb0ea4
#4 sha256:872d85394d85121345306f306f434d13ce6d5c37218196bd7dffdfa2b1185487
#4 resolve docker.io/library/python:3-alpine@sha256:dce56d40d885d2c8847aa2a278a29d50450c8e3d10f9d7ffeb2f38dcc1eb0ea4 done
#4 sha256:eb5bc7d10d52904953df1e5f3460f4f4154b7911603a3889a35ffcb9b6e75b81 7.44kB / 7.44kB done
#4 sha256:dce56d40d885d2c8847aa2a278a29d50450c8e3d10f9d7ffeb2f38dcc1eb0ea4 1.65kB / 1.65kB done
#4 sha256:affe0faa14e7553fc570beec3864e74b5e36f8c19b2bb49ae8ba79c0e9e7236e 1.37kB / 1.37kB done
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 0B / 11.69MB 0.2s
#4 sha256:c7f1ca1171d975af881f16ba8005f599918648448f8d9b0be5436dd8ba3bf1f0 0B / 231B 0.2s
#4 sha256:07a400e93df3fcc09e5f874878c049b15515236f55fbf76013c0779a7cc4a301 0B / 678.30kB 0.2s
#4 ...

#6 [internal] load build context
#6 sha256:aee7f93c830ef46880233dc3124788aef038bbe8de3409b585cd21fb82a805ae
#6 transferring context: 224.28kB 0.4s done
#6 DONE 0.4s

#4 [1/4] FROM docker.io/library/python:3-alpine@sha256:dce56d40d885d2c8847aa2a278a29d50450c8e3d10f9d7ffeb2f38dcc1eb0ea4
#4 sha256:872d85394d85121345306f306f434d13ce6d5c37218196bd7dffdfa2b1185487
#4 extracting sha256:07a400e93df3fcc09e5f874878c049b15515236f55fbf76013c0779a7cc4a301
#4 sha256:07a400e93df3fcc09e5f874878c049b15515236f55fbf76013c0779a7cc4a301 678.30kB / 678.30kB 0.7s done
#4 sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678 0B / 2.35MB 0.8s
#4 sha256:c7f1ca1171d975af881f16ba8005f599918648448f8d9b0be5436dd8ba3bf1f0 231B / 231B 0.8s done
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 1.05MB / 11.69MB 1.3s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 2.10MB / 11.69MB 1.7s
#4 sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678 851.97kB / 2.35MB 1.8s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 3.15MB / 11.69MB 1.9s
#4 sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678 1.05MB / 2.35MB 1.9s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 4.19MB / 11.69MB 2.2s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 5.11MB / 11.69MB 2.5s
#4 sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678 2.10MB / 2.35MB 2.5s
#4 extracting sha256:07a400e93df3fcc09e5f874878c049b15515236f55fbf76013c0779a7cc4a301 1.8s done
#4 sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678 2.35MB / 2.35MB 2.6s done
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 6.29MB / 11.69MB 2.9s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 7.34MB / 11.69MB 3.3s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 8.39MB / 11.69MB 3.4s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 9.44MB / 11.69MB 3.7s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 10.49MB / 11.69MB 4.0s
#4 sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 11.69MB / 11.69MB 4.3s done
#4 extracting sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7
#4 extracting sha256:d8c681bc2183ac2de0b5e117ed74647ee5dfbdbf8a3730ac81c54f3b3db989f7 1.9s done
#4 extracting sha256:c7f1ca1171d975af881f16ba8005f599918648448f8d9b0be5436dd8ba3bf1f0 0.0s done
#4 extracting sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678
#4 extracting sha256:dc9256fcea2e541f17f0ed7d4dae23c03fb27a5ab8e7611e34f5a5e4d96d6678 0.8s done
#4 DONE 7.9s

#5 [2/4] WORKDIR /app
#5 sha256:3950f014d35b49bf98a5879949830e8ec2d1550416ecdeee4c8c8fb4b7e4f7ae
#5 DONE 0.2s

#7 [3/4] ADD . /app
#7 sha256:4d081bbef88a4767a1dee00da10f33fa7bb8acd5399a584e0cb475395c6d1af5
#7 DONE 0.1s

#8 [4/4] RUN pip3 install -r requirements.txt -i https://pypi.douban.com/simple
#8 sha256:3d2f5aa66e7e509a9fce445f284d51b0a0beb154d76899c239d670f9fdb357d6
#8 4.862 Looking in indexes: https://pypi.douban.com/simple
#8 5.391 Collecting BeautifulReport
#8 5.446   Downloading https://pypi.doubanio.com/packages/b3/2c/b944e50172b72ce94f2b495a761e66ee3c4d517cee226469727749224f13/BeautifulReport-0.1.3.tar.gz (31 kB)
#8 6.567 Collecting ddt
#8 6.622   Downloading https://pypi.doubanio.com/packages/16/51/45518c5a2f3ffc7fa782db8e34d4c6a619765fe5d19809030c771da44cfd/ddt-1.4.4-py2.py3-none-any.whl (6.3 kB)
#8 6.996 Collecting Faker
#8 7.031   Downloading https://pypi.doubanio.com/packages/33/58/02649e1b42ef4188c4a5aaec2d2ea424f50576f481646f0685e27021deb1/Faker-11.3.0-py3-none-any.whl (1.2 MB)
#8 7.399 Collecting PyMySQL
#8 7.419   Downloading https://pypi.doubanio.com/packages/4f/52/a115fe175028b058df353c5a3d5290b71514a83f67078a6482cff24d6137/PyMySQL-1.0.2-py3-none-any.whl (43 kB)
#8 7.683 Collecting pytest
#8 7.698   Downloading https://pypi.doubanio.com/packages/40/76/86f886e750b81a4357b6ed606b2bcf0ce6d6c27ad3c09ebf63ed674fc86e/pytest-6.2.5-py3-none-any.whl (280 kB)
#8 8.087 Collecting PyYAML
#8 8.140   Downloading https://pypi.doubanio.com/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz (124 kB)
#8 8.844   Installing build dependencies: started
#8 21.95   Installing build dependencies: finished with status 'done'
#8 21.96   Getting requirements to build wheel: started
#8 24.04   Getting requirements to build wheel: finished with status 'done'
#8 24.04     Preparing wheel metadata: started
#8 24.65     Preparing wheel metadata: finished with status 'done'
#8 24.84 Collecting requests
#8 24.89   Downloading https://pypi.doubanio.com/packages/2d/61/08076519c80041bc0ffa1a8af0cbd3bf3e2b62af10435d269a9d0f40564d/requests-2.27.1-py2.py3-none-any.whl (63 kB)
#8 25.02 Collecting rsa
#8 25.04   Downloading https://pypi.doubanio.com/packages/30/ab/8fd9e88e6fa5ec41afca995938bbefb72195278e0cfc5bd76a4f29b23fb2/rsa-4.8-py3-none-any.whl (39 kB)
#8 25.24 Collecting unittestreport
#8 25.41   Downloading https://pypi.doubanio.com/packages/1f/ca/4523ea890c37b80fbf6d52222ec9a133293f0cb62cf285c1296b3f275286/unittestreport-1.4.0-py3-none-any.whl (58 kB)
#8 25.51 Collecting jsonpath
#8 25.53   Downloading https://pypi.doubanio.com/packages/5f/c0/b54189dfe62f1a93ba294ab53508a81d440fc63adff253db369f557a996a/jsonpath-0.82.tar.gz (9.6 kB)
#8 26.24 Collecting openpyxl
#8 26.26   Downloading https://pypi.doubanio.com/packages/1c/a6/8ce4d2ef2c29be3235c08bb00e0b81e29d38ebc47d82b17af681bf662b74/openpyxl-3.0.9-py2.py3-none-any.whl (242 kB)
#8 26.50 Collecting text-unidecode==1.3
#8 26.52   Downloading https://pypi.doubanio.com/packages/a6/a5/c0b6468d3824fe3fde30dbb5e1f687b291608f9473681bbf7dabbf5a87d7/text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
#8 26.90 Collecting python-dateutil>=2.4
#8 26.94   Downloading https://pypi.doubanio.com/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
#8 27.20 Collecting attrs>=19.2.0
#8 27.23   Downloading https://pypi.doubanio.com/packages/be/be/7abce643bfdf8ca01c48afa2ddf8308c2308b0c3b239a44e57d020afa0ef/attrs-21.4.0-py2.py3-none-any.whl (60 kB)
#8 27.32 Collecting iniconfig
#8 27.35   Downloading https://pypi.doubanio.com/packages/9b/dd/b3c12c6d707058fa947864b67f0c4e0c39ef8610988d7baea9578f3c48f3/iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
#8 27.46 Collecting pluggy<2.0,>=0.12
#8 27.48   Downloading https://pypi.doubanio.com/packages/9e/01/f38e2ff29715251cf25532b9082a1589ab7e4f571ced434f98d0139336dc/pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
#8 27.61 Collecting packaging
#8 27.64   Downloading https://pypi.doubanio.com/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl (40 kB)
#8 27.71 Collecting toml
#8 27.74   Downloading https://pypi.doubanio.com/packages/44/6f/7120676b6d73228c96e17f1f794d8ab046fc910d781c8d151120c3f1569e/toml-0.10.2-py2.py3-none-any.whl (16 kB)
#8 27.93 Collecting py>=1.8.2
#8 27.97   Downloading https://pypi.doubanio.com/packages/f6/f0/10642828a8dfb741e5f3fbaac830550a518a775c7fff6f04a007259b0548/py-1.11.0-py2.py3-none-any.whl (98 kB)
#8 28.31 Collecting urllib3<1.27,>=1.21.1
#8 28.34   Downloading https://pypi.doubanio.com/packages/4e/b8/f5a25b22e803f0578e668daa33ba3701bb37858ec80e08a150bd7d2cf1b1/urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
#8 28.54 Collecting certifi>=2017.4.17
#8 28.57   Downloading https://pypi.doubanio.com/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
#8 28.79 Collecting charset-normalizer~=2.0.0
#8 28.81   Downloading https://pypi.doubanio.com/packages/84/3e/1037abe6498e65d645ce7a22d3402605d49a3b2c7f20c3abb027760da4f0/charset_normalizer-2.0.10-py3-none-any.whl (39 kB)
#8 28.91 Collecting idna<4,>=2.5
#8 28.93   Downloading https://pypi.doubanio.com/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl (61 kB)
#8 29.21 Collecting pyasn1>=0.1.3
#8 29.26   Downloading https://pypi.doubanio.com/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
#8 29.31 Collecting PyYAML
#8 29.34   Downloading https://pypi.doubanio.com/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269 kB)
#8 30.42 Collecting Jinja2==3.0.3
#8 30.46   Downloading https://pypi.doubanio.com/packages/20/9a/e5d9ec41927401e41aea8af6d16e78b5e612bca4699d417f646a9610a076/Jinja2-3.0.3-py3-none-any.whl (133 kB)
#8 30.54 Collecting requests
#8 30.57   Downloading https://pypi.doubanio.com/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl (61 kB)
#8 30.63 Collecting idna<4,>=2.5
#8 30.65   Downloading https://pypi.doubanio.com/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58 kB)
#8 30.70 Collecting urllib3<1.27,>=1.21.1
#8 30.75   Downloading https://pypi.doubanio.com/packages/56/aa/4ef5aa67a9a62505db124a5cb5262332d1d4153462eb8fd89c9fa41e5d92/urllib3-1.25.11-py2.py3-none-any.whl (127 kB)
#8 30.85 Collecting chardet<4,>=3.0.2
#8 30.87   Downloading https://pypi.doubanio.com/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133 kB)
#8 31.24 Collecting MarkupSafe>=2.0
#8 31.27   Downloading https://pypi.doubanio.com/packages/04/69/c31e837e4bb5532b02d297152464b2cb8a0edeb9bef762c015e9b4e95e16/MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl (30 kB)
#8 31.36 Collecting et-xmlfile
#8 31.38   Downloading https://pypi.doubanio.com/packages/96/c2/3dd434b0108730014f1b96fd286040dc3bcb70066346f7e01ec2ac95865f/et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
#8 31.64 Collecting six>=1.5
#8 31.67   Downloading https://pypi.doubanio.com/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
#8 31.94 Collecting pyparsing!=3.0.5,>=2.0.2
#8 31.97   Downloading https://pypi.doubanio.com/packages/80/c1/23fd82ad3121656b585351aba6c19761926bb0db2ebed9e4ff09a43a3fcc/pyparsing-3.0.7-py3-none-any.whl (98 kB)
#8 32.04 Building wheels for collected packages: BeautifulReport, PyYAML, jsonpath
#8 32.04   Building wheel for BeautifulReport (setup.py): started
#8 32.70   Building wheel for BeautifulReport (setup.py): finished with status 'done'
#8 32.70   Created wheel for BeautifulReport: filename=BeautifulReport-0.1.3-py3-none-any.whl size=33101 sha256=80c327569e1801884ebbc292376d949364e7429805076c14dd176911a3df3d6b
#8 32.70   Stored in directory: /root/.cache/pip/wheels/c7/37/fa/bfe232474a845922df6d2cc3eedcf298a7ed6f99f705c8cf81
#8 32.71   Building wheel for PyYAML (setup.py): started
#8 33.62   Building wheel for PyYAML (setup.py): finished with status 'done'
#8 33.62   Created wheel for PyYAML: filename=PyYAML-5.3.1-cp310-cp310-linux_x86_64.whl size=44635 sha256=18c89b2cba0b5b138522fdf36c812707eae6de7242ee9a9c526f17a63ff4701a
#8 33.63   Stored in directory: /root/.cache/pip/wheels/31/da/33/e45f5aa9bbb53552b384354ee01ed8c96a0ac3cf2ec053535d
#8 33.64   Building wheel for jsonpath (setup.py): started
#8 34.70   Building wheel for jsonpath (setup.py): finished with status 'done'
#8 34.70   Created wheel for jsonpath: filename=jsonpath-0.82-py3-none-any.whl size=5612 sha256=a3966420e4054c87bcd805e93da0e6107f6781e247fa0ac7757fa5f7d926a78e
#8 34.71   Stored in directory: /root/.cache/pip/wheels/fe/7b/6b/3891918a1a9627043dc05b5c045772576acff162330cbf0d99
#8 34.72 Successfully built BeautifulReport PyYAML jsonpath
#8 35.13 Installing collected packages: urllib3, six, pyparsing, MarkupSafe, idna, chardet, certifi, toml, text-unidecode, requests, PyYAML, python-dateutil, pyasn1, py, pluggy, packaging, Jinja2, iniconfig, et-xmlfile, attrs, unittestreport, rsa, pytest, PyMySQL, openpyxl, jsonpath, Faker, ddt, BeautifulReport
#8 42.17 Successfully installed BeautifulReport-0.1.3 Faker-11.3.0 Jinja2-3.0.3 MarkupSafe-2.0.1 PyMySQL-1.0.2 PyYAML-5.3.1 attrs-21.4.0 certifi-2021.10.8 chardet-3.0.4 ddt-1.4.4 et-xmlfile-1.1.0 idna-2.10 iniconfig-1.1.1 jsonpath-0.82 openpyxl-3.0.9 packaging-21.3 pluggy-1.0.0 py-1.11.0 pyasn1-0.4.8 pyparsing-3.0.7 pytest-6.2.5 python-dateutil-2.8.2 requests-2.24.0 rsa-4.8 six-1.16.0 text-unidecode-1.3 toml-0.10.2 unittestreport-1.4.0 urllib3-1.25.11
#8 42.17 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#8 42.20 WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
#8 42.20 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
#8 DONE 43.3s

#9 exporting to image
#9 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#9 exporting layers
#9 exporting layers 1.2s done
#9 writing image sha256:e97396f4b4caa88cf5a198d5be2e262c7159c5921553b893245fbac068e5bcc0 done
#9 naming to docker.io/library/py42test done
#9 DONE 1.2s
+ docker run --rm py42test
[2022-01-24 10:15:00,395-test_log-INFO-/app/tools/handle_log.py-42]: test
[2022-01-24 10:15:01,047-test_log-INFO-/app/tools/handle_excel.py-16]: Name of case data file/app/test_data/testCase.xlsx
[2022-01-24 10:15:01,050-test_log-INFO-/app/tools/handle_excel.py-17]: sheet Name of all
[2022-01-24 10:15:01,107-test_log-INFO-/app/tools/handle_excel.py-28]: Test data obtained from use case data file
[{'id': 1, 'title': 'Login successful', 'method': 'post', 'url': 'http://api. lemonban. com/futureloan/member/login', 'data': '{"mobile_phone":"18100000009","pwd":"Aa123456"}', 'replace_ sql': None, 'expected_ data': '{"code": 0, "msg": "OK"}', 'extract_ data': '{"token":"$..token","member_id":"$..id"}', 'setup_ sql': None, 'check_ db': None, 'check_ db_ Dynamic ': none}, {' ID ': 2,' title ':' recharge succeeded ',' method ':' post ',' URL ':' http://api.lemonban.com/futureloan/member/recharge ', 'data': '{"member_id":"#member_id#","amount":100}', 'replace_ sql': None, 'expected_ data': '{"code": 0, "msg": "OK"}', 'extract_ data': None, 'setup_ sql': None, 'check_ db': None, 'check_ db_ Dynamic ': none}, {' ID ': 3,' title ':' successful investment ',' method ':' post ',' URL ':' http://api.lemonban.com/futureloan/member/invest ', 'data': '{"loan_id":"#loan_id#","member_id":"#member_id#","amount":100}', 'replace_ sql': '["SELECT id AS loan_id FROM loan WHERE STATUS = 2 ORDER BY ID DESC LIMIT 1"]', 'expected_ data': '{"code": 0, "msg": "OK"}', 'extract_ data': None, 'setup_ sql': '["update loan set status=2  where status !=2  order by id desc limit 1"]', 'check_ db': None, 'check_ db_ Dynamic ': 1}, {ID': 4, 'title': 'approval succeeded', 'method': 'patch', 'URL': ' http://api.lemonban.com/futureloan/loan/audit ', 'data': '{"loan_id":"#loan_id#", "approved_or_not":True }', 'replace_ sql': '["SELECT id AS loan_id FROM loan WHERE STATUS=1 ORDER BY id DESC LIMIT 1"]', 'expected_ data': '{"code": 0, "msg": "OK"}', 'extract_ data': None, 'setup_ sql': '["update loan set status=1  where status !=1 order by id desc limit 1"]', 'check_ db': None, 'check_ db_ Dynamic ': none}, {' ID ': 5,' title ':' 36 months after the success of the new project ',' method ':' post ',' URL ':' http://api.lemonban.com/futureloan/loan/add ','data': '{member_id': '#member_id#', 'title': \ 'monthly standard 36 months \', 'amount': 1000, "loan_rate": 10.0, "loan_term": 36, "loan_date_type": 1, "bidding_days": 10} ','replace'_ sql': None, 'expected_ data': '{"code": 0, "msg": "OK"}', 'extract_ data': '{"loan_id":"$..id"}', 'setup_ sql': None, 'check_ db': '{"actual_data":"select amount from loan where id = #loan_id#","expect_data":1000}', 'check_ db_ Dynamic ': none}, {ID': 6, 'title': 'get user information', 'method': 'get', 'URL': '/ Member / #member_id# / Info', 'data': none, 'replace_sql': none, 'expected_data': '{"code": 0, "MSG": "OK"}','extract '_ data': None, 'setup_ sql': None, 'check_ db': None, 'check_ db_ dynamic': None}]
[2022-01-24 10:15:01,270-test_log-INFO-/app/test_case/test_all.py-46]: Currently executed use case data

[2022-01-24 10:15:01,273-test_log-INFO-/app/test_case/test_all.py-53]: setup_sql The field is empty and does not need to be preceded Sql sentence
[2022-01-24 10:15:01,274-test_log-INFO-/app/tools/handle_replace.py-82]: Parameters replace the data passed in:
{"mobile_phone":"18100000009","pwd":"Aa123456"}
[2022-01-24 10:15:01,275-test_log-INFO-/app/tools/handle_replace.py-83]: Use case data field replace_sql Incoming data:
None
[2022-01-24 10:15:01,275-test_log-INFO-/app/tools/handle_replace.py-86]: data Data is not empty, start parameter replacement
[2022-01-24 10:15:01,276-test_log-INFO-/app/tools/handle_replace.py-88]: The parameter fields to be replaced are:
[]
[2022-01-24 10:15:01,277-test_log-INFO-/app/tools/handle_replace.py-103]: No parameter replacement is required, and the return is converted to dict Type of data
[2022-01-24 10:15:01,406-test_log-INFO-/app/test_case/test_all.py-46]: Currently executed use case data

[2022-01-24 10:15:01,407-test_log-INFO-/app/test_case/test_all.py-53]: setup_sql The field is empty and does not need to be preceded Sql sentence
[2022-01-24 10:15:01,410-test_log-INFO-/app/tools/handle_replace.py-82]: Parameters replace the data passed in:
{"member_id":"#member_id#","amount":100}
[2022-01-24 10:15:01,411-test_log-INFO-/app/tools/handle_replace.py-83]: Use case data field replace_sql Incoming data:
None
[2022-01-24 10:15:01,413-test_log-INFO-/app/tools/handle_replace.py-86]: data Data is not empty, start parameter replacement
[2022-01-24 10:15:01,415-test_log-INFO-/app/tools/handle_replace.py-88]: The parameter fields to be replaced are:
['member_id']
[2022-01-24 10:15:01,415-test_log-INFO-/app/tools/handle_replace.py-90]: key_list Not null, start parameter replacement
[2022-01-24 10:15:01,416-test_log-INFO-/app/tools/handle_replace.py-91]: Get the data according to the source of the data, and then set it as a class attribute
[2022-01-24 10:15:01,420-test_log-INFO-/app/tools/handle_replace.py-55]: Replace parameter key=member_id
[2022-01-24 10:15:01,421-test_log-INFO-/app/tools/handle_replace.py-71]: This replacement method is not supported temporarily. Please check the replacement rules
[2022-01-24 10:15:01,421-test_log-INFO-/app/tools/handle_replace.py-93]: Get the data according to the data source and set it as the class property has been completed
[2022-01-24 10:15:01,422-test_log-INFO-/app/tools/handle_replace.py-95]: Start to get parameters from class properties and replace them
[2022-01-24 10:15:01,423-test_log-INFO-/app/tools/handle_replace.py-97]: Replace the name of the parameter key=member_id
[2022-01-24 10:15:01,424-test_log-INFO-/app/tools/handle_replace.py-98]: Replace parameter value value=770683
[2022-01-24 10:15:01,424-test_log-INFO-/app/tools/handle_replace.py-100]: After parameter replacement, the replaced parameters are:
{"member_id":"770683","amount":100}convert to dict Type of data and return
[2022-01-24 10:15:01,583-test_log-INFO-/app/test_case/test_all.py-46]: Currently executed use case data

[2022-01-24 10:15:01,584-test_log-INFO-/app/test_case/test_all.py-49]: Start pre execution sql sentence
[2022-01-24 10:15:01,585-test_log-INFO-/app/tools/handle_db.py-42]: Executive sql The statement is:
update loan set status=2  where status !=2  order by id desc limit 1
[2022-01-24 10:15:01,646-test_log-INFO-/app/tools/handle_replace.py-82]: Parameters replace the data passed in:
{"loan_id":"#loan_id#","member_id":"#member_id#","amount":100}
[2022-01-24 10:15:01,647-test_log-INFO-/app/tools/handle_replace.py-83]: Use case data field replace_sql Incoming data:
["SELECT id AS loan_id FROM loan WHERE STATUS = 2 ORDER BY ID DESC LIMIT 1"]
[2022-01-24 10:15:01,647-test_log-INFO-/app/tools/handle_replace.py-86]: data Data is not empty, start parameter replacement
[2022-01-24 10:15:01,648-test_log-INFO-/app/tools/handle_replace.py-88]: The parameter fields to be replaced are:
['loan_id', 'member_id']
[2022-01-24 10:15:01,650-test_log-INFO-/app/tools/handle_replace.py-90]: key_list Not null, start parameter replacement
[2022-01-24 10:15:01,650-test_log-INFO-/app/tools/handle_replace.py-91]: Get the data according to the source of the data, and then set it as a class attribute
[2022-01-24 10:15:01,654-test_log-INFO-/app/tools/handle_replace.py-48]: replace_sql Not empty,Need to execute sql Statement to get parameters and set them as class properties
[2022-01-24 10:15:01,655-test_log-INFO-/app/tools/handle_replace.py-27]: implement sql sentence:
SELECT id AS loan_id FROM loan WHERE STATUS = 2 ORDER BY ID DESC LIMIT 1
[2022-01-24 10:15:01,657-test_log-INFO-/app/tools/handle_db.py-42]: Executive sql The statement is:
SELECT id AS loan_id FROM loan WHERE STATUS = 2 ORDER BY ID DESC LIMIT 1
[2022-01-24 10:15:01,705-test_log-INFO-/app/tools/handle_replace.py-29]: implement sql The result of the statement:
[{'loan_id': 51662}]
[2022-01-24 10:15:01,706-test_log-INFO-/app/tools/handle_replace.py-32]: ergodic sql Execute the result and set it as class property
[2022-01-24 10:15:01,708-test_log-INFO-/app/tools/handle_replace.py-21]: Class attribute key=loan_id,value=51662
[2022-01-24 10:15:01,709-test_log-INFO-/app/tools/handle_replace.py-55]: Replace parameter key=loan_id
[2022-01-24 10:15:01,710-test_log-INFO-/app/tools/handle_replace.py-71]: This replacement method is not supported temporarily. Please check the replacement rules
[2022-01-24 10:15:01,710-test_log-INFO-/app/tools/handle_replace.py-55]: Replace parameter key=member_id
[2022-01-24 10:15:01,712-test_log-INFO-/app/tools/handle_replace.py-71]: This replacement method is not supported temporarily. Please check the replacement rules
[2022-01-24 10:15:01,714-test_log-INFO-/app/tools/handle_replace.py-93]: Get the data according to the data source and set it as class property. It is finished
[2022-01-24 10:15:01,714-test_log-INFO-/app/tools/handle_replace.py-95]: Start to get parameters from class properties and replace them
[2022-01-24 10:15:01,715-test_log-INFO-/app/tools/handle_replace.py-97]: Replace the name of the parameter key=loan_id
[2022-01-24 10:15:01,715-test_log-INFO-/app/tools/handle_replace.py-98]: Replace parameter value value=51662
[2022-01-24 10:15:01,717-test_log-INFO-/app/tools/handle_replace.py-100]: After parameter replacement, the replaced parameters are:
{"loan_id":"51662","member_id":"#member_id#"," amount":100} convert to data of dict type and return
[2022-01-24 10:15:01,717-test_log-INFO-/app/tools/handle_replace.py-97]: Replace the name of the parameter key=member_id
[2022-01-24 10:15:01,719-test_log-INFO-/app/tools/handle_replace.py-98]: Replace parameter value value=770683
[2022-01-24 10:15:01,719-test_log-INFO-/app/tools/handle_replace.py-100]: After parameter replacement, the replaced parameters are:
{"loan_id":"51662","member_id":"770683","amount":100}convert to dict Type and return
[2022-01-24 10:15:01,946-test_log-INFO-/app/test_case/test_all.py-46]: Currently executed use case data

[2022-01-24 10:15:01,947-test_log-INFO-/app/test_case/test_all.py-49]: Start pre execution sql sentence
[2022-01-24 10:15:01,949-test_log-INFO-/app/tools/handle_db.py-42]: Executive sql The statement is:
update loan set status=1  where status !=1 order by id desc limit 1
[2022-01-24 10:15:02,001-test_log-INFO-/app/tools/handle_replace.py-82]: Parameters replace the data passed in:
{"loan_id":"#loan_id#", "approved_or_not":True }
[2022-01-24 10:15:02,001-test_log-INFO-/app/tools/handle_replace.py-83]: Use case data field replace_sql Incoming data:
["SELECT id AS loan_id FROM loan WHERE STATUS=1 ORDER BY id DESC LIMIT 1"]
[2022-01-24 10:15:02,002-test_log-INFO-/app/tools/handle_replace.py-86]: data Data is not empty, start parameter replacement
[2022-01-24 10:15:02,003-test_log-INFO-/app/tools/handle_replace.py-88]: The parameter fields to be replaced are:
['loan_id']
[2022-01-24 10:15:02,004-test_log-INFO-/app/tools/handle_replace.py-90]: key_list Not null, start parameter replacement
[2022-01-24 10:15:02,004-test_log-INFO-/app/tools/handle_replace.py-91]: Get the data according to the source of the data, and then set it as a class attribute
[2022-01-24 10:15:02,004-test_log-INFO-/app/tools/handle_replace.py-48]: replace_sql Not empty,Need to execute sql Statement to get parameters and set them as class properties
[2022-01-24 10:15:02,005-test_log-INFO-/app/tools/handle_replace.py-27]: implement sql sentence:
SELECT id AS loan_id FROM loan WHERE STATUS=1 ORDER BY id DESC LIMIT 1
[2022-01-24 10:15:02,006-test_log-INFO-/app/tools/handle_db.py-42]: Executive sql The statement is:
SELECT id AS loan_id FROM loan WHERE STATUS=1 ORDER BY id DESC LIMIT 1
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-29]: implement sql The result of the statement:
[{'loan_id': 51662}]
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-32]: ergodic sql Execute the result and set it as class property
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-21]: Class attribute key=loan_id,value=51662
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-55]: Replace parameter key=loan_id
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-71]: This replacement method is not supported temporarily. Please check the replacement rules
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-93]: Get the data according to the data source and set it as class property. It is finished
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-95]: Start to get parameters from class properties and replace them
[2022-01-24 10:15:02,056-test_log-INFO-/app/tools/handle_replace.py-97]: Replace the name of the parameter key=loan_id
[2022-01-24 10:15:02,057-test_log-INFO-/app/tools/handle_replace.py-98]: Replace parameter value value=51662
[2022-01-24 10:15:02,057-test_log-INFO-/app/tools/handle_replace.py-100]: After parameter replacement, the replaced parameters are:
{"loan_id":"51662", "approved_or_not":True }convert to dict Type and return
[2022-01-24 10:15:02,161-test_log-INFO-/app/test_case/test_all.py-46]: Currently executed use case data

[2022-01-24 10:15:02,162-test_log-INFO-/app/test_case/test_all.py-53]: setup_sql The field is empty and does not need to be preceded Sql sentence
[2022-01-24 10:15:02,162-test_log-INFO-/app/tools/handle_replace.py-82]: Parameters replace the data passed in:
{"member_id":"#member_id#"," title ": 'monthly standard 36 months'," amount":1000,"loan_rate":10.0,"loan_term":36,"loan_date_type":1,"bidding_days":10}
[2022-01-24 10:15:02,163-test_log-INFO-/app/tools/handle_replace.py-83]: Use case data field replace_sql Incoming data:
None
[2022-01-24 10:15:02,163-test_log-INFO-/app/tools/handle_replace.py-86]: data Data is not empty, start parameter replacement
[2022-01-24 10:15:02,164-test_log-INFO-/app/tools/handle_replace.py-88]: The parameter fields to be replaced are:
['member_id']
[2022-01-24 10:15:02,166-test_log-INFO-/app/tools/handle_replace.py-90]: key_list Not null, start parameter replacement
[2022-01-24 10:15:02,167-test_log-INFO-/app/tools/handle_replace.py-91]: Get the data according to the source of the data, and then set it as a class attribute
[2022-01-24 10:15:02,170-test_log-INFO-/app/tools/handle_replace.py-55]: Replace parameter key=member_id
[2022-01-24 10:15:02,170-test_log-INFO-/app/tools/handle_replace.py-71]: This replacement method is not supported temporarily. Please check the replacement rules
[2022-01-24 10:15:02,171-test_log-INFO-/app/tools/handle_replace.py-93]: Get the data according to the data source and set it as class property. It is finished
[2022-01-24 10:15:02,171-test_log-INFO-/app/tools/handle_replace.py-95]: Start to get parameters from class properties and replace them
[2022-01-24 10:15:02,172-test_log-INFO-/app/tools/handle_replace.py-97]: Replace the name of the parameter key=member_id
[2022-01-24 10:15:02,172-test_log-INFO-/app/tools/handle_replace.py-98]: Replace parameter value value=770683
[2022-01-24 10:15:02,173-test_log-INFO-/app/tools/handle_replace.py-100]: After parameter replacement, the replaced parameters are:
{"member_id":"770683","title":'Monthly standard 36 months',"amount":1000,"loan_rate":10.0,"loan_term":36,"loan_date_type":1,"bidding_days":10}convert to dict Type and return
[2022-01-24 10:15:02,331-test_log-INFO-/app/test_case/test_all.py-46]: Currently executed use case data

[2022-01-24 10:15:02,332-test_log-INFO-/app/test_case/test_all.py-53]: setup_sql The field is empty and does not need to be preceded Sql sentence
[2022-01-24 10:15:02,335-test_log-INFO-/app/tools/handle_replace.py-82]: Parameters replace the data passed in:
None
[2022-01-24 10:15:02,338-test_log-INFO-/app/tools/handle_replace.py-83]: Use case data field replace_sql Incoming data:
None
[2022-01-24 10:15:02,339-test_log-INFO-/app/tools/handle_replace.py-107]: data The parameter is empty. There is no need to replace the parameter,Return empty{}
token No, no authentication required
 There is no need to replace the requested address
 wrong V3 The authentication method does not need to be processed
['eyJhbGciOiJIUzUxMiJ9.eyJtZW1iZXJfaWQiOjc3MDY4MywiZXhwIjoxNjQzMDE5NjAxfQ._qaV51oOi12Nke0DNhX8ck4XzNrFFe5qvLULRYBM-ItxE6FJHCCC4I3aoRRdIn1KT4GGOlHSYDnyFcpmqE484g']
[770683]
eyJhbGciOiJIUzUxMiJ9.eyJtZW1iZXJfaWQiOjc3MDY4MywiZXhwIjoxNjQzMDE5NjAxfQ._qaV51oOi12Nke0DNhX8ck4XzNrFFe5qvLULRYBM-ItxE6FJHCCC4I3aoRRdIn1KT4GGOlHSYDnyFcpmqE484g 770683
 No database assertion is required
test_all_001 (test_all.TestAll)Execute——>[[adopted]
This replacement method is not supported yet
 There is no need to replace the requested address
extract_data Null, no need to response Extract parameters from
 No database assertion is required
test_all_002 (test_all.TestAll)Execute——>[[adopted]
This replacement method is not supported yet
 This replacement method is not supported yet
 Balance before interface request: 183000.0
 There is no need to replace the requested address
extract_data Null, no need from response Extract parameters from
 No database assertion is required
 Balance after interface request: 182900.0
test_all_003 (test_all.TestAll)Execute——>[[adopted]
This replacement method is not supported yet
 There is no need to replace the requested address
extract_data Null, no need from response Extract parameters from
 No database assertion is required
test_all_004 (test_all.TestAll)Execute——>[[adopted]
This replacement method is not supported yet
 There is no need to replace the requested address
[51663]
eyJhbGciOiJIUzUxMiJ9.eyJtZW1iZXJfaWQiOjc3MDY4MywiZXhwIjoxNjQzMDE5NjAxfQ._qaV51oOi12Nke0DNhX8ck4XzNrFFe5qvLULRYBM-ItxE6FJHCCC4I3aoRRdIn1KT4GGOlHSYDnyFcpmqE484g 770683
 Expansion of other channels
select amount from loan where id = 51663========
select amount from loan where id = 51663--------------------
test_all_005 (test_all.TestAll)Execute——>[[adopted]
extract_data Null, no need from response Extract parameters from
 No database assertion is required
test_all_006 (test_all.TestAll)Execute——>[[adopted]
All use cases have been executed and the test report is being generated......
The test report has been generated. The report path is:/app/reports/report.html
Finished: SUCCESS

5, Summary

jenkins container - start the python container - execute the automation framework in the python container
Construction process: start jenkins - pull code from remote warehouse - execute Dockerfile to create image - start container automation framework based on image
1. Start jenkins and configure:
1. Start a jenkins container through the jenkins image
2. Enables jenkins to execute the docker command of the host
-v /var/run/docker.sock:/var/run/docker.sock
-v /usr/bin/docker:/usr/bin/docker
3. The written Dockerfile and requirements Txt into the project directory and upload it to the remote warehouse
4. Configure jenkins build operation command
docker build -t py42test .
docker run --rm py42test

2. Write Dockerfile file to build python automatic environment image
FROM python:3-alpine
WORKDIR /app
ADD . /app
RUN pip3 install -r requirements.txt -i https://pypi.douban.com/simple
CMD ["python3", "main.py"]
1. Select python image
2. Switch working directory
3. Add the automation code pulled down by jenkins to the working directory of the python container
4. Dependent packages required to install the automation environment:
pip3 install freeze > requirements.txt
pip3 install -r python.txt -i https://pypi.douban.com/simple
5. Sets the default command to execute after the container runs
CMD ["python3", "main.py"]

Keywords: Docker jenkins macOS

Added by YoussefSiblini on Mon, 24 Jan 2022 13:41:41 +0200