Jenkins用户权限问题
在Ubuntu下做apk的重签名工作,我手动执行脚本没问题,但是用jenkins执行报下面的错误,猜想估计是权限问题,如果提升jenkins的权限升级为root是不是问题就没了呢,所以就开始尝试各种方法提升jenkins的权限,下面是实现方法
I: Baksmaling...
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
W: Could not decode attr value, using undecoded value instead: ns=android, name=versionCode, value=0x000002a9
W: Could not decode attr value, using undecoded value instead: ns=android, name=versionName, value=0x00000029
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Writer.java:157)
at brut.androlib.res.util.ExtMXSerializer.writeAttributeValue(ExtMXSerializer.java:38)
at org.xmlpull.mxp1_serializer.MXSerializer.attribute(MXSerializer.java:673)
at org.xmlpull.v1.wrapper.classic.XmlSerializerDelegate.attribute(XmlSerializerDelegate.java:106)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.writeStartTag(StaticXmlSerializerWrapper.java:267)
at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.event(StaticXmlSerializerWrapper.java:211)
at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:80)
at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:130)
at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:144)
at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:131)
at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:218)
at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:115)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:114)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)
rename step 1
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.PathNotExist: apktool.yml
at brut.androlib.Androlib.readMetaFile(Androlib.java:164)
at brut.androlib.Androlib.build(Androlib.java:183)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.directory.PathNotExist: apktool.yml
at brut.directory.AbstractDirectory.getFileInput(AbstractDirectory.java:103)
at brut.androlib.Androlib.readMetaFile(Androlib.java:160)
在Ubuntu下,当执行apt-get install方式安装Jenkins的时候,会自动创建jenkins用户,这是一个没有用户目录的账号。
检查了一下,居然在nogroup组中,下面的调整修复了这两个权限问题:
1.从/etc/group文件中在nogroup中删除jenkins账号
2.将jenkins账号分别加入到root组中
gpasswd -a root jenkins
3.修改/etc/default/jenkins文件中,
# user id to be invoked as (otherwise will run as root; not wise!)
JENKINS_USER=root
JENKINS_GROUP=root