jenkins error on staring via cmd, using war 2.9 - jenkins

I am trying to start jenkins via command prompt but getting
jenkins error on staring via cmd, using war 2.9
org.xmlpull.v1.XmlPullParserException: only 1.0 is supported as <?xml version not '1.1' (position: START_DOCUMENT seen <?xml version=\'1.1\'... #1:19)
at org.xmlpull.mxp1.MXParser.parseXmlDeclWithVersion(MXParser.java:2608)
at org.xmlpull.mxp1.MXParser.parseXmlDecl(MXParser.java:2592)
at org.xmlpull.mxp1.MXParser.parsePI(MXParser.java:2466)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1447)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(

You have file with invalid XML version, you can replace it using Jenkins Issue 49450 answer:
ran this command in $JENKINS_HOME:
find . -name "*.xml" -print -exec sed -i '.bak' "s/xml version='1.1'/xml version='1.0'/" {} \;

Related

Working bin/bas returns error when executed from run script Xcode

I have a working shell script that works with no problems but when I executed it with a run script i get the following error:
The script will scan all the proto files in a directory and convert it to Swift using ProtoBuf. After that I will move the swift files into an App folder. The script code is the following
#!/bin/bash
for protoFile in ./*.proto;
do
protoc --swift_out=. $protoFile
done
for file in ./*.swift;
do
mv $file ../Convert\ AV/Model/USBDongle/Proto/
done
Any ideas?
Thank you
I was calling the script from the directory it was located. When Xcode executes the the script that assumption is false. So I am getting the directory where the script is located and I do the logic with that path
#!/bin/bash
#Get Directory where the script is located
baseDirectory=$(dirname "$0")
echo "$baseDirectory"
for protoFile in "$baseDirectory"/*.proto
do
echo $protoFile
protoc --swift_out="$baseDirectory" -I "$baseDirectory" "$protoFile"
done
for protoFileSwift in "$baseDirectory"/*.swift;
do
echo $protoFile
mv "$protoFileSwift" "$baseDirectory"/../Convert\ AV/Model/USBDongle/Proto
done
* /* Makes like is a comment... *

Install specific version of a plugin with install-plugin command

I cant see examples of how to do this:
https://jenkins.io/doc/book/managing/plugins/
I backup a list of all plugins installed and their versions.
I want to use install-plugin command to install all plugins (and their specific versions) from the list.
I dont see option to specify version to install-plugin command
To install a specific version you can run the command and pass a parameter with a colon like this:
install-plugins.sh git:3.9.1
or alternatively add the list of plugins to a file (plugins.txt for instance):
git:3.9.1
saml:1.0.7
and run it with the following command:
install-plugins.sh plugins.txt
You can download jar file from here: https://github.com/jenkinsci/plugin-installation-manager-tool
$ rm -rf /usr/share/jenkins/plugins/ldap*
$ ls /usr/share/jenkins/plugins/ldap*
ls: cannot access '/usr/share/jenkins/plugins/ldap*': No such file or directory
$ echo $JAVA_OPTS
-Djenkins.install.runSetupWizard=false
$ java $JAVA_OPTS -jar /opt/jenkins-plugin-manager-2.12.8.jar --plugins ldap:2.7
Done
$ ls /usr/share/jenkins/plugins/ldap*
/usr/share/jenkins/plugins/ldap.jpi
$ echo "http://<jenkins-url>/restart"
http://<jenkins-url>/restart
$ ls /usr/share/jenkins/plugins/ldap*
/usr/share/jenkins/plugins/ldap.jpi
/usr/share/jenkins/plugins/ldap:
META-INF WEB-INF
$ cat /usr/share/jenkins/plugins/ldap/META-INF/MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: rsandell
Build-Jdk: 1.8.0_211
Extension-Name: ldap
Specification-Title: The Jenkins Plugins Parent POM Project
Implementation-Title: ldap
Implementation-Version: 2.7
Group-Id: org.jenkins-ci.plugins
Short-Name: ldap
Long-Name: LDAP Plugin
Url: https://github.com/jenkinsci/ldap-plugin
Compatible-Since-Version: 1.16
Minimum-Java-Version: 1.8
Plugin-Version: 2.7
Hudson-Version: 2.277.1
Jenkins-Version: 2.277.1
Plugin-Dependencies: mailer:1.34
Plugin-Developers:
Plugin-License-Name: The MIT license
Plugin-License-Url: https://opensource.org/licenses/MIT
Plugin-ScmUrl: https://github.com/jenkinsci/ldap-plugin

Jenkins Console Print Encoded Characters

When outputting characters from a declarative pipeline running inside a linux container is it possible to change the encoding to match the true output from the terminal? I.e.
├── file1 +-- file1
├── file2 +-- file2
└── file3 +-- file3
^Formatting I want ^Formatting I get
.
I tried passing the following arguments to my Docker Agent:
-e JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8"
-e LC_ALL="en_US.UTF-8"
.
Combined with:
sh returnStdout: true, script: " "
And got ├── in place of the "+--", which seems to be the ANSI encoding for the "├──".
I am using the ansiColor Option but that didn't seem to help much.
.
I saw this similar question, but I was unsure on how to implement the solution in the pipeline.
Jenkins: console output characters
You can use Jenkins II to change the encoding to UTF-8.
Go to
Jenkins -> Manage Jenkins -> Configure System -> Global properties
and add two envirenment variables JAVA_TOOL_OPTIONS and LANG having values -Dfile.encoding=UTF-8 and en_US.UTF-8 respectively
.
After adding these you may need to restart Jenkins.
Reference: https://www.linkedin.com/pulse/how-resolve-utf-8-encoding-issue-jenkins-ajuram-salim/
UPDATE:
or you can update <arguments> in jenkins.xml file.
e.g.
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dfile.encoding=UTF-8 -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
Here is the official answer from cloudbees. Unfortunately all of these did not work for me.
https://support.cloudbees.com/hc/en-us/articles/360004397911-How-to-address-issues-with-unmappable-characters-
Add these to JVM Arguments in master and also on agents -
-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
For me, the problem was really in specifying the optional 'encoding' parameter to the 'sh' pipeline step: sh: Shell Script
Of course, this will only work provided the file.encoding is set properly as described in other posts here.

How to edit "Version: xxx" from a script to automate a debian package build?

The Debian control file has a line like this (among many others):
Version: 1.1.0
We are using jenkins to build our application as a .deb package. in Jenkins we are doing something like this:
cp -r $WORKSPACE/p1.1/ourap/scripts/ourapp_debian $TARGET/
cd $TARGET
fakeroot dpkg-deb --build ourapp_debian
We would like to do shomething like this in our control file:
Packages: ourapp
Version: 1.1.$BUILD_NUMBER
but obviously this is not possible.
So we need something like a sed script to find the line starting with Version: and replace anything after it with a constant plus the BUILD_NUMBER env var which Jenkins creates.
We have tried things like this:
$ sed -i 's/xxx/$BUILD_NUMBER/g' control
then put "Version: xxx" in our file, but this doesn't work, and there must be a better way?
Any ideas?
We don't use the change-log, as this package will be installed on servers which no one has access to. the change logs are word docs given to the customer.
We don't use or need any of the Debian helper tools.
Create two files:
f.awk
function vp(s) { # return 1 for a string with version info
return s ~ /[ \t]*Version:/
}
function upd() { # an example of version number update function
v[3] = ENVIRON["BUILD_NUMBER"]
}
vp($0) {
gsub("[^.0-9]", "") # get rid of everything but `.' and digits
split($0, v, "[.]") # split version info into array `v' elements
upd()
printf "Version: %s.%s.%s\n", v[1], v[2], v[3]
next # done with this line
}
{ # print the rest without modifications
print
}
f.example
rest1
Version: 1.1.0
rest2
Run the command
BUILD_NUMBER=42 awk -f f.awk f.example
Expected output is
rest1
Version: 1.1.42
rest2
With single quote:
sed -ri "s/(Version.*\.)[0-9]*/\1$BUILD_NUMBER/g" <control file>
OR
sed -ni "/Version/{s/[0-9]*$/$BUILD_NUMBER/};p" <control file>

Using Xbuild with Xamarin.Android (formerly Mono for Android)

We have a Xamarin.Android project that we are trying to build using Jenkins on a Mac. The Solution file contains several different projects, one of which is the MonoDroid project. The MonoDroid Project is dependent upon the other projects in the solution.
The problem that I have is that when I use xbuild to build the solution file, I have no way to use the /t:PackageForAndroid target, since it only is valid for the MD Project File.
Currently in Jenkins, I'm doing it like this:
xbuild MyCoolDroidAp/MyCoolDroidApp.sln /p:Configuration=Release /t:Clean
xbuild MyCoolDroidApp/MyCoolDroidApp.sln /p:Configuration=Release /t:Build
xbuild MyCoolDroidApp/MyCoolDroidProject.csproj /p:Configuration=Release /t:PackageForAndroid
This is working, but it seems to me that there should be a way to eliminate the 3rd step. Does anyone have any insight?
You don't need to use Xamarin.Studio/MonoDevelop to sign & zipalign your APK, you can do that at the command line. I've had luck using rake to compile, sign, and zipalign my APK files. Would something like that work for you?
Failing that, here is a simple Powershell script that you could probably port over real easy:
# First clean the Release target.
msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:Clean
# Now build the project, using the Release target.
msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:PackageForAndroid
# At this point there is only the unsigned APK - sign it.
# The script will pause here as jarsigner prompts for the password.
# It is possible to provide they keystore password for jarsigner.exe by adding an extra command line parameter -storepass, for example
# -storepass <MY_SECRET_PASSWORD>
# If this script is to be checked in to source code control then it is not recommended to include the password as part of this script.
& 'C:\Program Files\Java\jdk1.6.0_24\bin\jarsigner.exe' -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ./xample.keystore -signedjar
./bin/Release/mono.samples.helloworld-signed.apk
./bin/Release/mono.samples.helloworld.apk publishingdoc
# Now zipalign it. The -v parameter tells zipalign to verify the APK afterwards.
& 'C:\Program Files\Android\android-sdk\tools\zipalign.exe' -f -v 4
./bin/Release/mono.samples.helloworld-signed.apk ./helloworld.apk
Hope this helps.
The consensus around the interwebs seems to be that I am doing this the right way.
Regarding Signing your apk i'm using something like this as a part of my makefile and it works ok:
...
BUILD_DIR = ./builds/$(platform)
KEYSTORE_PATH = your_keystore_pass
STORE_PASS = your_keystore_pass
ANDROID_SDK_PATH = path/to/your/android/sdk/dir
#example ANDROID_SDK_PATH = /Developer/AndroidSDK
RES_APK = my_apk.apk
APK_NAME = my_signed_apk.apk
...
sign:
(cd $(BUILD_DIR); jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore $(KEYSTORE_PATH) -storepass $(STORE_PASS) result.apk $(STORE_PASS))
(cd $(BUILD_DIR); $(ANDROID_SDK_PATH)/tools/zipalign -v 4 result.apk $(APK_NAME))
(cd $(BUILD_DIR);rm result.apk)
(cd $(BUILD_DIR);rm $(RES_APK))
Hope this helps

Resources