jenkins not executing last shell command - jenkins

I have a CI project in jenkins just to run some tests and send a report via email.
Running it from a docker console(or ubuntu) there is no probelm , it runs the test and send the report via email.
But when i try to run the same command on jenkins it never runs the last command in order to send the report via email.
Here is the command
python3 -m venv . && . bin/activate && pip3 install -r requirements.txt && pytest testcases/HotelesCI/Desktop/HotelPlaya --html=/home/jenkins/hoteles_playa_desktop.html --reruns 2 --self-contained-html --tb=line -k 'test_errors' ; python3 testcases/HotelesCI/Desktop/HotelPlaya/hotels_report.py
Again if i copy and paste into a console there is no probelm
I even try to run the last command in another build shell step , but nothing happens
Am i missing something? there is no output in jenkins for the las command

Solved even i don fully understand why , changing the last concatenation quote from " ; " to " || ", it solves the problem.
As i understand , the first option should run the last command always even on build failure , and my change is telling the system that run it only on failure

Related

How do you print to console from a docker file during build?

Suppose you have some Dockerfile. What needs to be added to that file such that a string (ie "Hello World") is printed to the console during build?
docker build .
RESEARCH
This question is a top hit in Google for this topic. I have researched by googling and landing here.
WHAT I HAVE TRIED
From the accepted answer:
RUN echo "hello there"
This actually doesn't work.
It's fairly simple actually.
If you just want to print stuff using in the build proccess you could just add the following line to your Dockerfile:
RUN echo "hello there"
And then add these options to your docker build command:
--progress=plain --no-cache
EDIT:
as noted by #SoftwareEngineer, when used for logging or tooling purposes you should append the echo command to the one you want to check if were successful. for example when downloading packages and wanting to get a print statement when finished:
example from nginx official image dockerfile
RUN apt-get install -y whatever && echo "installed package"

Jenkins/Robot Framework - looking for chromedriver but I think it's in PATH

Hey in Jenkins I'm trying to run robot framework tests:
with command python3 robot -d results mytestsuite.robot, and it has some line to open chrome browser, but the message in log shows me typical: WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see...
Everything works ok locally, and I'm not sure which PATH jenkins wants to use so my questions are:
why do I have to input python3 instead of python (with just python in command it tells me that robot is not found)
why chromedriver is not found, and how to set it up (in what PATH and how) to make it work
Is it possible to set jenkins up to use other drivers ex. geckodriver?
My jenkins job env looks like this:
#!/bin/bash
echo $JENKINS_HOME
which python3
echo $PATH
outputs:
/Users/MYUSER/.jenkins
/usr/bin/python3
/Users/MYUSER/.jenkins/tools/chromedriver:/usr/bin:/bin:/usr/sbin:/sbin
Ok so I've fixed it with:
export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin/:$PATH
this is the location where I have chromedriver locally.
in the build shell execute but is there a way to make it more permanent (I mean not to use it every time it runs build?)

How to install Web Services Enhancements (WSE) 3.0 in a Dockerfile

I'm attempting to containerize a legacy ASP.NET application that has a dependency on Web Services Enhancements (WSE) 3.0. I understand that this is a legacy technology but refactoring the application to remove it is not an option.
My Dockerfile:
FROM mcr.microsoft.com/windows/servercore/iis
RUN mkdir prereqs
WORKDIR /prereqs
COPY ["prereqs/WSE30.msi", "c:/prereqs/"]
RUN "C:\prereqs\WSE30.msi /qn /quiet /passive"
Which fails with the following:
The command 'cmd /S /C "C:\prereqs\WSE30.msi /qn /quiet /passive"' returned a non-zero code: 1603
I've tried modifying the RUN command to include logging...
RUN "C:\prereqs\WSE30.msi /qn /quiet /passive /lv c:/logs/wse30.txt"
...but this creates a condition where the docker build just seems to hang; I've let several of these attempts run for more than an hour and they do not appear to progress or complete.
I've also tried adding an "exit 0" to simply let the build continue if there is an error...
RUN "C:\prereqs\WSE30.msi /qn /quiet /passive /lv c:/logs/wse30.txt" ; exit 0
..but the result is the same. The build appears to hang and never complete.
I know that this particular MSI supports unattended/silent installation as I've done so in batch files.
#DWRoelands , I faced the same issue but I was able to install it on the windowservercore:1909 after installing the all web-serverr and all its subcomponents components.
You will have to set the source of .Net3.5 to the downloaded file of https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft-windows-netfx3-1909.zip

Combine two commands into one statement

In Linux I have the following RUN:
RUN dotnet restore Backend &&\
dotnet publish Backend --output /opt/src/Publish
Now I try to do it for windows container:
RUN dotnet restore IPBackend &\
dotnet publish IPBackend --output /app/publish
However I get this message:
The ampersand (&) character is not allowed. The & operator is reserved for
future use; wrap an ampersand in double quotation marks ("&") to pass it as
part of a string.
For && it also throws an error.
I fixed it by the following code:
RUN dotnet restore Backend ;\
dotnet publish Backend --output /app/publish
It works fine but I try to understand whether is it correct way or not?
If yes could anybody give a link with description?
'&&' is for command chaining it will execute command based on succesfull execution of previous command. ';' doesnt care for result of previous command and will execute even when previous command is failed.
'&' you can fork your 2 commands so a command will start executing without waiting for previous command to finish.
I would like 2 see errors you encountered with &&

wget command error in jenkins

I am trying to run below command using Jenkins shell:
wget -r --no-parent --reject "index.html*" http://${IP}/ranjans/ -P ${WORKSPACE}/tests
File is getting downloaded but my Jenkins job is marked failure. Am I missing anything here?
You might try looking at the no clobber option. I wonder if you are getting a bad result from wget because you are running this multiple times, and wget is complaining because the files already exist.
To double check that it is indeed wget that is failing, try printing out the exit value of wget. If it is 0, its a problem elsewhere.

Resources