What provides PageUtils and PagedIterable for the Bitbucket API? - bitbucket

I am trying to find what provides the packages:
com.atlassian.bitbucket.util.PageUtils;
com.atlassian.bitbucket.util.PagedIterable;
I have looked in:
Bitbucket API
Bitbucket SCM Common
Bitbucket SPI

The PageUtils class is part of bitbucket-util jar. https://packages.atlassian.com/maven-external/com/atlassian/bitbucket/server/bitbucket-util/
Just add a dependency
<dependency>
<groupId>com.atlassian.bitbucket.server</groupId>
<artifactId>bitbucket-util</artifactId>
<scope>provided</scope>
</dependency>

Related

How to inject Jenkins environmental variables into pom.xml

I'm developing plugin for Atlassian Jira and trying to get the version number of my plugin to be equal Jenkins BUILD_NUMBER environment variable.
Plugin is built inside docker container using command:
docker run --rm --volume $PWD/src/jira_plugin/:/opt/atlas/ codeclou/docker-atlassian-sdk:latest atlas-package
POM.xml:
<project>
<version>${jenkins.buildNumber}</version>
...
<properties>
<jenkins.buildNumber>${env.BUILD_NUMBER}</jenkins.buildNumber>
</properties>
</project>
Result:
[INFO] Building jar: /opt/atlas/target/test-null.jar ..[ERROR] Failed
to execute goal
com.atlassian.maven.plugins:maven-jira-plugin:6.3.15:generate-obr-artifact
(default-generate-obr-artifact) on project test: Source
'/opt/atlas/target/test${env.BUILD_NUMBER}.jar' does not exist
Nevertheless command
echo `printenv`
in docker correctly displays BUILD_NUMBER var.
Question:
What should I add in pom.xml to inject BUILD_NUMBER var in pom.xml and to display version correctly?
Any help would be greatly appreciated.
I figured it out:
docker run -e BUILD_NUMBER="${BUILD_NUMBER}" ...
So the variable will be injected and can be used in pom.xml.

Generate pom file for non-Maven artifact in Jenkins

I have a tar.gz artifact that gets uploaded to Artifactory using Jenkins. Since this artifact is not based on a Maven project, there is no pom file and thus no maven-metadata.xml being generated in Artifactory. The latter being very useful for versioning, etc.
Is there any way to have Jenkins generate a pom file for a non-Maven project?
With a manual deploy on artifactory you can generate a pom.xml ,unfortunately this option is not available on the jenkins artifactory's plugin, but you can maybe create you own shell script , like :
#!/bin/bash
groupId=com.mycompany
artifactId=myproject
version=1.0.0
echo '<?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>'$groupId'</groupId>
<artifactId>'$artifactId'</artifactId>
<version>'$version'</version>
<description>Artifactory auto generated POM</description>
</project>' >> pom.xml
Anyway depending on your build tool and how you create the tar.gz package you can may be find more solutions ..
Regards

Jenkins's maven release plugin - How to set parent project version?

I have a multi-modules project that I want to release with Jenkins. I use Maven 3.3.1, Jenkins 1.651.3 and maven-release-plugin 0.14.0
I create one job for the parent project and one job for each sub project.
Here is the parent configuration :
pom.xml :
<groupId>parent.group.id</groupId>
<artifactId>parent-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<scm>
<url>http://mygitrepo/parent-project.git</url>
<connection>scm:git:git://mygitrepo/parent-project.git</connection>
<developerConnection>scm:git:http://mygitrepo/parent-project.git</developerConnection>
</scm>
Jenkins config :
When I perform maven release for the parent project, it works.
Now I do the same thing for a sub project.
pom.xml :
<parent>
<groupId>parent.group.id</groupId>
<artifactId>parent-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<scm>
<url>http://mygitrepo/sub-project.git</url>
<connection>scm:git:git://mygitrepo/sub-project.git</connection>
<developerConnection>scm:git:http://mygitrepo/sub-project.git</developerConnection>
</scm>
With the same Jenkins config. I got this error :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project sub-project: Can't release project due to non released dependencies :
[ERROR] parent.group.id:parent-artifact:pom:1.0.0-SNAPSHOT
The plugin doesn't seem to replace the parent version by the release version.
I read in the maven release plugin's documentation that I can use "-Dproject.dev" and "-Dproject.rel" to specify the parent version to use.
So I tried this :
-Dproject.dev.parent.group.id:parent-artifact=1.0.1-SNAPSHO
-Dproject.rel.parent.group.id:parent-artifact=1.0.0
release:clean release:prepare release:perform -X
-Dproject.dev.parent.group.id:parent-artifact:pom=1.0.1-SNAPSHOT
-Dproject.rel.parent.group.id:parent-artifact:pom=1.0.0
release:clean release:prepare release:perform -X
-Dproject.dev.parent.group.id:parent-artifact:pom:1.0.0-SNAPSHOT=1.0.1-SNAPSHOT
-Dproject.rel.parent.group.id:parent-artifact:pom:1.0.0-SNAPSHOT=1.0.0
release:clean release:prepare release:perform -X
None of this solve the problem.
How can I configure Jenkins plugin to set the parent-project version ?
As an alternative you could use the Versions Maven Plugin to set the parent version in an own build step:
mvn versions:update-parent
or to set a specific version
mvn versions:update-parent "-DparentVersion=[1.2.0]"

maven not downloading google-gson

I haved added the below lines in my pom.xml.Still I can't find gson-2.2.4.jar in my local maven repository.
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>
What can be the possible reason for this.? The version of Maven that I am using is
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_NZ, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-37-generic", arch: "amd64", family: "unix"

Integration of jbehave with jenkins

I have to integrate jbehave with jenkins. But I don't have idea how to do this. I saw that I have to create a task in Jenkins, but I don't know where I should wire jbehave with this task.
Can somebody help me?
Thanks,
Sarang
So I'm assuming you have JBehave integrated with Maven, correct?
The simple build environment can be set up as follows:
Go to Jenkins and add a new job of type "Build a maven2/3 project"
Configure your project to check out your from whatever source repository you use.
Configure the build phase of the project to run whatever Maven goal you need ("install" will probably work)
Hit save and you have a working project that will execute exactly as it would from a command line.
If you want to see the JBehave test output rendered nicely in Jenkins you should also follow these instructions to configure the Jenkins/XUnit plugin: http://jbehave.org/reference/stable/hudson-plugin.html
You will also need to make sure your project is configured to use the XML Output format in your StoryReporterBuilder to make use of the plugin (not mentioned in the instructions above).
You can visit the following for details:
http://jbehave.org/reference/stable/hudson-plugin.html
Per your comments, you want to specify the stories to run via Jenkins when using the Maven plugin. Here is one way:
Create a subclass of StoryFinder and set it as the storyFinderClass property in your Maven configuration. In the Jenkins commandline launcher, you can pass in stories as a -D system property which can then be read from your StoryFinder.
Commandline
mvn ... -Dcom.sarang.stories="foo.story,bar.story"
Maven
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>[version]</version>
<executions>
<execution>
<id>run-stories-as-embeddables</id>
<phase>integration-test</phase>
<configuration>
...
<systemProperties>
<property>
<name>com.sarang.stories</name>
<value>${com.sarang.stories}</value>
</property>
</systemProperties>
<storyFinderClass>com.sarang.MyStoryFinder</storyFinderClass>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
...
</goals>
</execution>
</executions>
</plugin>
StoryFinder
package com.sarang;
import org.jbehave.core.io.StoryFinder;
import java.util.*;
public class MyStoryFinder extends StoryFinder {
#Override
protected List<String> scan(String basedir, List<String> includes,
List<String> excludes) {
//List<String> defaultStories = super.scan(basedir, includes, excludes);
String myStories = System.getProperty("com.sarang.stories");
return Arrays.asList(myStories.split(","));
}
}

Resources