From a2ff2e8b38cdd51871da640249f10830f5bcb83c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 24 Feb 2022 11:10:07 +0100 Subject: [PATCH] chore: decouple ansible install from execution (#2163) (#2166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 8503f0948197056e7d0714ac0a7d30244101980d) Co-authored-by: Manuel de la Peña --- .ci/Jenkinsfile | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 440e2538b9..bf3edc7b3d 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -351,18 +351,31 @@ def pyrun(command){ [var: "AWS_ACCESS_KEY_ID", password: awsAuthObj.access_key], [var: "AWS_SECRET_ACCESS_KEY", password: awsAuthObj.secret_key] ]) { - sh(script: """#!/bin/bash - set -eux - if ! test -d ${env.WORKSPACE}/.venv; then - python3 -m venv ${env.WORKSPACE}/.venv - ${env.WORKSPACE}/.venv/bin/pip3 -q install wheel - ${env.WORKSPACE}/.venv/bin/pip3 -q install -r .ci/ansible/requirements.txt - ${env.WORKSPACE}/.venv/bin/ansible-galaxy install -r .ci/ansible/requirements.yml - fi - ${env.WORKSPACE}/.venv/bin/${command} - """, - label: "Executing ${command.split(' ')[0]}" - ) + retryWithSleep(retries: 3, seconds: 5, backoff: true){ + sh(script: """#!/bin/bash + set -eux + if ! test -f ${env.WORKSPACE}/.venv-installed; then + python3 -m venv ${env.WORKSPACE}/.venv + touch ${env.WORKSPACE}/.venv-installed + fi + """, + label: "Creating virtualenv" + ) + } + retryWithSleep(retries: 3, seconds: 30, backoff: true){ + sh(script: """#!/bin/bash + set -eux + if ! test -f ${env.WORKSPACE}/.python-dependencies; then + ${env.WORKSPACE}/.venv/bin/pip3 -q install wheel + ${env.WORKSPACE}/.venv/bin/pip3 -q install -r .ci/ansible/requirements.txt + ${env.WORKSPACE}/.venv/bin/ansible-galaxy install -r .ci/ansible/requirements.yml + touch ${env.WORKSPACE}/.python-dependencies + fi + """, + label: "Installing dependencies" + ) + } + sh(script: "${env.WORKSPACE}/.venv/bin/${command}", label: "Executing ${command.split(' ')[0]}") } } }