I want to add the Jenkins build number to my file pom.xml. I can do this with the Maven Version plugin , but first I need the original version from the file pom.xml.
For this, I use the command xmllint --xpath '/project/version/text()' pom.xml. However, I keep gettingXPath set is empty
Here's an example file pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>das-artifact</artifactId>
<name>das-name</name>
<version>4.2</version>
</project>
And here is my conclusion:
$ xmllint
XPath set is empty
$
However, if I change the item xmlnsto fooxmlns, it works:
Here's an example file pom.xml:
<project fooxmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>das-artifact</artifactId>
<name>das-name</name>
<version>4.2</version>
</project>
And here is my conclusion:
$ xmllint --nsclean --xpath '/project/version/text()' pom.xml
4.2$
I am not too familiar with everything that can be done xmllint. Can I make it ignore the namespace attribute xmlns?
source
share