Issue
I am generating an RPM package using jenkins, although SOURCE, BUILD, BUILDROOT are all stored under /var/lib/jenkins/rpmbuild/, the rpm package after generation gets redirected to /root/rpmbuild/RPMS and I get error as
error: cannot create /root/rpmbuild/RPMS/noarch: Permission denied
I tried creating /var/lib/jenkins/rpmbuild/RPMS/noarch but it failed, I checked my .rpmmacro too and there I have defined topdir as
%_topdir %(echo $HOME)/rpmbuild
and owner and group of .rpmmacro is jenkins
I want the rpm package to get stored under /var/lib/jenkins/rpmbuild/RPMS/noarch/ as the task is build by jenkins and that's the only directory that jenkins owns.
Solution
To answer my own question,
There is a key in spec file called %define
, you just need to define the directory or path where you want your rpm package to save. You just need to define it for the first time if you are using same spec file for every build.
for me it was
%define _rpmdir /root/rpmbuild/RPMS/
which I changed to
%define _rpmdir /var/lib/jenkins/rpmbuild/RPMS/
and it started working
Answered By - abhishek Answer Checked By - Willingham (WPSolving Volunteer)