master-simtrace2 failed to build from October 19 onwards: $WORKSPACE environment missing
When we write a "contrib/jenkins.sh" job, we assume that all the jenkins environment variables as documented at https://wiki.jenkins.io/display/JENKINS/Building+a+software+project are available to the script. In the specific case, $WORKSPACE was used, which failed after the job had been moved inside docker.
- https://jenkins.osmocom.org/jenkins/job/master-simtrace2/a1=default,a2=default,a3=default,a4=default,label=osmocom-master-debian9/540/console is the last working log
- https://jenkins.osmocom.org/jenkins/job/master-simtrace2/a1=default,a2=default,a3=default,a4=default,label=osmocom-master-debian9/541/console is the first failing job.
I think it's generally a good idea to make sure all the jenkins environment variables as described at the link above are passed into the docker container, so authors of contrib/jenkins.sh don't have to consider undocumented osmocom-docker-specific restrictions but can use the normal set of environment variables..
For $WORKSPACE, it's questionable what to do. Probably best we mount it into the docker container, and then specify that mount point as "-e WORKSPACE"?
I would prefer if jenkins.sh scripts tried to avoid using these variables. Because the more jenkins specific variables they use, the more effort it is to run the jenkins.sh script locally, outside of jenkins, for testing (as one has to provide dummy values for all of them). And the more room there is for errors, when getting one of the variables wrong and having the script potentially taking a different code path.
With that in mind, I would not pass any of these variables to docker.
Is that fine with you?
you have a valid point. However, the problem is we then have to specify what kind of assumptions we can make when writing those scripts. For example, using "/build" suffers from exactly the same problem as you describe, just that instead of $WORKSPACE (which you as the user can override) you now have to locally create a /build directory and give write permissions for your local user to it :/
- Status changed from New to In Progress
- % Done changed from 0 to 90
I have updated the wiki page "Jenkins build verification jobs" to list all available environment variables:
Here is a patch to add it to the yml files, so we remember to keep them in sync: