ジェンキンスは、Gitのリポジトリのコードの実行Pythonスクリプトの自動化を引くことを学ぶ5、ジェンキンス

序文

Pythonはgitのリポジトリの完了後に提出するスクリプト開発を自動化し、次のステップは、ジェンキンスビルドオートメーションコードを使用するようにコードを引っ張っています

gitのソースコード管理

コードアップロードgitリポジトリは、ここで提示されていない、関連このgithubの前に書かれて見ることができhttps://www.cnblogs.com/yoyoketang/p/7302515.html
自分の家は、あなたがこれを参照することができ、一般的な使用gitlab HTTPS ://www.cnblogs.com/yoyoketang/p/10282529.html

新しいフリースタイル・プロジェクト・ジェンキンスを開きます。

ソース管理

  • リポジトリのURLアドレスコードリポジトリ
  • 資格情報は、リポジトリのログインIDとパスワードの資格情報をgitの
  • 指定されたブランチ(空の代理として任意の)デフォルトのブランチ*/master

リポジトリのURLアドレスコードリポジトリ

注:SSHの方法は、右上隅ポイントSSHアドレスにリンクされている場合

ジェンキンスボタンを開く資格情報は、gitのリポジトリのログインIDとパスワードを入力してください

実行シェルの構築

シェル、最初のPIP3のインストールrequirements.txtを実行した後、スクリプトを実行しpytest

コンソール入力をチェックし、ログの表示を慰めます

+ ls
requirements.txt
test_demo.py
+ pip3 install -r requirements.txt
Collecting requests==2.18.4 (from -r requirements.txt (line 1))
  Downloading 

Installing collected packages: idna, urllib3, requests, atomicwrites, six, more-itertools, wcwidth, attrs, py, zipp, importlib-metadata, pluggy, pytest, pytest-metadata, pytest-html
  Found existing installation: idna 2.8
    Uninstalling idna-2.8:
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/var/jenkins_home/python3/lib/python3.6/site-packages/idna-2.8.dist-info/INSTALLER'
Consider using the `--user` option or check the permissions.

インストールする許可を見つかりませんでした、容器の内部に設置することができます

ドッキングウィンドウのexec -it -uルート容器のID / binに/ bashの

オープンワークスペースのインストールディレクトリ/ home /ジェンキンス/ワークスペース/ pytest_demo

[root@cb8e397d5308]# cd /home/jenkins/workspace/pytest_demo
[root@cb8e397d5308]# ls
requirements.txt  test_demo.py
[root@cb8e397d5308]# pip3 install -r requirements.txt

インストールが完了した後pytestチェックpytestを入力します。-bash:pytestを:コマンドが見つかりません。

[root@VM_0_2_centos pytest_demo]# pytest
-bash: pytest: command not found

ソフトリンクを追加するpytestインストールアドレスを検索し、pytest --version視聴環境を入力してください

[root@cb8e397d5308]# find / -name pytest
/var/jenkins_home/python3/bin/pytest
[root@cb8e397d5308]# ln -s /var/jenkins_home/python3/bin/pytest /usr/bin/pytest
[root@cb8e397d5308]# pytest --version
This is pytest version 4.5.0, imported from /root/python36/lib/python3.6/site-packages/pytest.py
setuptools registered plugins:
  pytest-html-1.19.0 at /root/python36/lib/python3.6/site-packages/pytest_html/plugin.py
  pytest-metadata-1.8.0 at /root/python36/lib/python3.6/site-packages/pytest_metadata/plugin.py

ビルドジョブ

上記の環境は、インストール、シェルの実装を完了するために必要とされた後、pytest直接入力コマンドは、自動化されたスクリプトを実行することができます

成功の構築

おすすめ

転載: www.cnblogs.com/yoyoketang/p/12129847.html