Daniel Beck
Daniel Beck

Reputation: 6513

Identifying exact component versions of a build artifact

How can I set up a Jenkins based build process (using Artifactory Pro for artifact storage) of a fairly complex product so that the version/revision of each of its components can be easily identified?

Some of these components might have been created from other components (essentially, an aggregation), so those sub-component revisions would need to be identifiable in turn.

I'd rather not build and the complete (large) product all the time, archiving its sources along with it, instead using previously created artifacts. During development, they'd likely have a SNAPSHOT version that is used for a while.

When, during testing, an issue is discovered, how can I trace it back to the exact source control revisions of each of the completed product's components for analysis? We don't use SVN for everything, and there's no Jenkins plugin for the other VCS.


Some of what we do is based on Maven, but solutions should be flexible enough to not require a Maven project in Jenkins.

Upvotes: 0

Views: 466

Answers (1)

khmarbaise
khmarbaise

Reputation: 97399

You can use the maven-buildnumber-plugin to get the revision number from Subversion and put this information into the MANIFEST file.

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.3.1</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              </manifest>
              <manifestEntries>
                  <buildNumber>${buildNumber}</buildNumber>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>

The following snippet will call the buildNumber plugin and use a different string for the version if no SVN working copy exists. May be this can be replaced by the Job_ID of jenkins etc.

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.0-beta-4</version>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
          <goal>create</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <revisionOnScmFailure>git</revisionOnScmFailure>
      <doCheck>false</doCheck>
      <doUpdate>false</doUpdate>
      <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
    </configuration>
  </plugin>

Upvotes: 1

Related Questions