I have gitlab CI pipeline, it always passed although my python script failed.
I have a URI that calls different apis and fetches data. It uses many URI some uri is not working, and it got failed to fetch data, but still it is making passed to the CI pipeline whether it should expect to fail.
How can I make ci pipeline failed if my pyscript failed.
I have below code
def connect(url,port):
##code that connecting url
end
error =[]
with concurrent.futures.ThreadPoolExecutor(max_workers=25) as executor:
# Start the load operations and mark each future with its URL
future_to_conn = {executor.submit(connect, host, 22): host for host in arr}
for future in concurrent.futures.as_completed(future_to_conn):
url = future_to_conn[future]
try:
data = future.result()
except Exception as exc:
print('%r generated an exception: %s' % (url, exc))
errors.append('generated an exception: '+ exec)
else:
print("Completed")
if(len(errors) > 0):
sys.exit("Execptin occured ", str(errors))
print("---------------------------------------------------------------------------")
print("Execution completed")
I have below simple Dockerfile FROM pyth3... USER root WORKDIR ./
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "./app.py"]
and
script.sh
echo "starting build--------------"
docker build -f Dockerfile -t python .
echo "Build Completed-------------"
docker run --rm -u $(id -u):$(id -g) -v "$PWD":/mnt python './app.py'
gitlab simple file
Run Python:
stage: deploy
script: (./script.sh Git=True Cron=False Detail=NA)
allow_failure: true
although I am using sys.exit("...") still not failing the pipeline it is always showing passed