Bug when returning Files to a Build Result using Jenkins
Hello,
I am using RTC 6.0.4, Jenkins 2.164.2 and Team Concert Jenkins Plugin 1.3.0
I think I have found a bug in the RTC Jenkins Integration and am seeking a workaround.
I have setup polling from Jenkins which works fine and builds initiated from RTC work fine
I use a pipeline and within that a checkout of a build definition, the checkout step works fine and then I call an ANT script to return some files, that bit is broken.
When the build is initiated from RTC the buildResultUUID property is filled by RTC
When it is initiated from Jenkins it is probably overwritten by Jenkins somehow - anyway it's blank, ideally this would be filled by RTC after the checkout step runs.
The build result artifact is however definitely generated and I can get at the UUID using the
RTCBuildResultUUID variable which appears to be a twin of the buildResultUUID
Things do not work fine when the build is initiated from Jenkins
What I have that others may not have is an ANT script that I run within a jenkins pipeline to return generated Results and logs to sit on the build result
I run ant using the batch step within a withCredentials and a withAnt block and pass the UUID successfully to the buildResultUUID ANT property
ant -f build.xml -DbuildResultUUID=-ohjlkjhlkjhljkhlkjhkfddgf -.....
the UUID is correct when I check the incomplete result in RTC, it seems that I cannot write to the buildResult when the build is initiated from Jenkins. I get the following sort of error (something is not initiated properly on the build definition when it is initiated from Jenkins, seems like a bug?):-
com.ibm.team.repository.common.itemNotFoundException: CRJAZ0215E The following record was not found in the database com.ibm.team.build.internal.common.model.impl.BuildResultHandelImpl@c7c4b5fc (stateId: null, itemId: [UUID _vhGsdfsfsdsdfsfsf], origin: <unset>, immutable: <unset>)
Note I check the UUID afterwards in RTC and it is as passed to the ANT file, very annoying ;-)
Any workaround suggestions?
Cheers
Richard
Accepted answer
//def checkOutVars = checkout([$class: 'RTCScm', avoidUsingToolkit: false, buildTool: 'RTC 6.0.4', buildType: [buildDefinition: 'PCU-TSS build', customizedSnapshotName: '', value: 'buildDefinition'], credentialsId: 'bigNumber', overrideGlobal: true, serverURI: 'serverUrl', timeout: 480])
def checkOutVars =teamconcert buildType: [buildDefinition: 'PCU-TSS build', value: 'buildDefinition'], overrideConfig: [buildTool: 'RTC 6.0.4', credentialsId: 'bigNumber', serverURI: 'serverUrl']
Any reason for using the teamconcert step and not the checkout step? teamconcert step is outdated. But I doubt if that would be the reason for the failure.
We have a similar setup in our test environment, where we invoke startBuildActivity and completeBuildActivilty from inside an ant script in a pipeline job. It works fine even when we run the build from Jenkins.
Can you please check if the repository address passed to the ant task is same when the build is requested from RTC as well as Jenkins?
Comments
3 other answers
Stack Trace:-
com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215E The following record was not found in the database: com.ibm.team.build.internal.common.model.impl.BuildResultHandleImpl@c7c4b5fc (stateId: null, itemId: [UUID _vhG68ZaUEemwwtJiYVVnAQ], origin: <unset>, immutable: <unset>)
at com.ibm.team.repository.common.internal.marshal.util.MarshallerUtil.decodeExceptions(MarshallerUtil.java:369)
at com.ibm.team.repository.common.internal.marshal.util.MarshallerUtil.decodeExceptions(MarshallerUtil.java:339)
at com.ibm.team.repository.common.internal.marshal.util.MarshallerUtil.decodeFault(MarshallerUtil.java:304)
at com.ibm.team.repository.transport.client.RemoteTeamService.constructExceptionFromFault(RemoteTeamService.java:717)
at com.ibm.team.repository.transport.client.RemoteTeamService.executeMethod(RemoteTeamService.java:560)
at com.ibm.team.repository.transport.client.RemoteTeamService.invoke(RemoteTeamService.java:202)
at com.ibm.team.repository.transport.client.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:43)
at com.sun.proxy.$Proxy16.startBuildActivity(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invokeServiceCall(ServiceInterfaceProxy.java:254)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:110)
at com.sun.proxy.$Proxy16.startBuildActivity(Unknown Source)
at com.ibm.team.build.internal.client.TeamBuildClient$1StartBuildActivityRunnable.run(TeamBuildClient.java:315)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runRunnable(OperationAdviceManager.java:1466)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.execute(OperationAdviceManager.java:208)
at com.ibm.team.process.internal.client.ProcessClientService.execute(ProcessClientService.java:774)
at com.ibm.team.build.internal.client.TeamBuildClient$9.run(TeamBuildClient.java:329)
at com.ibm.team.repository.client.internal.TeamRepository$3.run(TeamRepository.java:1328)
at com.ibm.team.repository.common.transport.CancelableCaller.call(CancelableCaller.java:79)
at com.ibm.team.repository.client.internal.TeamRepository.callCancelableService(TeamRepository.java:1323)
at com.ibm.team.build.internal.client.AbstractTeamBuildClient.callCancelableService(AbstractTeamBuildClient.java:268)
at com.ibm.team.build.internal.client.TeamBuildClient.startBuildActivity(TeamBuildClient.java:323)
at com.ibm.team.build.ant.task.StartBuildActivityTask.updateBuildResult(StartBuildActivityTask.java:153)
at com.ibm.team.build.ant.task.AbstractPublisherTask.doExecute(AbstractPublisherTask.java:105)
at com.ibm.team.build.ant.task.AbstractTeamBuildTask.execute(AbstractTeamBuildTask.java:1003)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Pipeline script:-
def timestamp = Calendar.getInstance().getTime().format('YYYYMMdd-hhmm')
echo(timestamp)
def resultsFile= outDir + '\DeployFolder' + timestamp +'.zip'
def deployZipFile = 'DeployFolder' + timestamp +'.zip'
def deployTermZipFile = 'Deploy_TermFolder' + timestamp +'.zip'
def bResult
echo(resultsFile)
node {
def mvnHome
stage('Preparation') { // for display purposes
//def checkOutVars = checkout([$class: 'RTCScm', avoidUsingToolkit: false, buildTool: 'RTC 6.0.4', buildType: [buildDefinition: 'PCU-TSS build', customizedSnapshotName: '', value: 'buildDefinition'], credentialsId: 'bigNumber', overrideGlobal: true, serverURI: 'serverUrl', timeout: 480])
def checkOutVars =teamconcert buildType: [buildDefinition: 'PCU-TSS build', value: 'buildDefinition'], overrideConfig: [buildTool: 'RTC 6.0.4', credentialsId: 'bigNumber', serverURI: 'serverUrl']
echo("Check env version")
bResult= "$env.RTCBuildResultUUID"
buildResultUUID=bResult
echo("${bResult}")
echo env.buildEngineId
echo env.repositoryAddress
echo "SnapshotUUID"
def snappy = "$env.team_scm_snapshotUUID"
echo "${snappy}"
}
stage('Run Build') {
dir(BuildDir) {
bat label: '', script: 'deploy.bat'
bat label: '', script: 'term_deploy.bat'
}
}
stage('Results') {
//changes current directory for any commands run inside it
dir(buildDir) {
//zip up folder contents to include on build
zip archive: true, dir: './deploy', glob: '', zipFile: deployZipFile
zip archive: true, dir: './term_deploy', glob: '', zipFile: deployTermZipFile
//could include log files etc here, but information seems to go to standard out
}
//Polling does not work from RTC, the build runs every time regardless if there are changes, check
if(buildResultUUID != "") {
withCredentials([usernamePassword(credentialsId: 'somebigNumber', passwordVariable: 'password', usernameVariable: 'userId')]) {
dir(BuildDir) {
//If this build was ran from RTC then use ANT to store results
withAnt(installation: 'ANT-DEFAULT', jdk: 'IBMJDK') {
bat label: '', script: 'ant -f returnFilesAndLogs.xml -DrepositoryAddress=%repositoryAddress% -DbuildResultUUID=' + buildResultUUID + ' -DdeployResultsZip=' + deployZipFile + ' -DdeployTermResultsZip=' + deployTermZipFile + ' -DuserId=%userId% -Dpassword=%password% -lib C:\IBM\TeamConcert_6.0.4\TeamConcertBuild_6.0.4\buildsystem\buildtoolkit'
}
}
}
}
}
}
An ANT file to run:-
<!--
This needs to be initiated from RTC in order to return things to a build result
Everything apart from the copying of results and log files back to RTC can be done better in
Jenkins
This bit will error if the build is run directly from Jenkins, maybe capture this by checking for
null buildResultUUID in pipeline
password and userId are passed in using the withCredentials wrapper
-->
<project name="returnData" default="all">
<target name="all" depends="checkEnv">
<!-- Update the build progress in Jazz by starting a new build activity. -->
<startBuildActivity activityIdProperty="postResultsId"
label="posting Artefacts..."
buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}" />
<!-- Publish some downloadable artifacts. Files published with the
artifactFilePublisher are shown on the Downloads tab of the build
result editor. -->
<tstamp>
<format property="timePortion" pattern="yyyyMMdd-HHmm" />
</tstamp>
<artifactFilePublisher buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
verbose="true"
filePath="${deployResultsZip}"
label="A suitable label" />
<artifactFilePublisher buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
verbose="true"
filePath="${deployTermResultsZip}"
label="Another label" />
<buildResultPublisher label="MyBuildLabel ${timePortion}"
buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}" />
<!-- Complete the compile build activity. -->
<completeBuildActivity activityId="${postResultsId}"
buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}" />
</target>
<target name="checkEnv">
<fail message="The repositoryAddress property must be defined."
unless="repositoryAddress" />
<echo message="Using repositoryAddress = ${repositoryAddress}" />
<fail message="The buildResultUUID property must be defined."
unless="buildResultUUID" />
<echo message="Using buildResultUUID = ${buildResultUUID}" />
<fail message="The userId property must be defined." unless="userId" />
<echo message="Using userId = ${userId}" />
<fail message="The password property must be defined."
unless="password" />
<!-- Don't echo the password. -->
</target>
<!-- These task definitions make the Jazz ant tasks available to this build file.
In order to find these classnames at run time, ant must be invoked with:
-lib <buildsystem-location>/buildtoolkit
-->
<taskdef name="buildResultPublisher"
classname="com.ibm.team.build.ant.task.BuildResultPublisherTask" />
<taskdef name="artifactFilePublisher"
classname="com.ibm.team.build.ant.task.ArtifactFilePublisherTask" />
<taskdef name="artifactLinkPublisher"
classname="com.ibm.team.build.ant.task.ArtifactLinkPublisherTask" />
<taskdef name="filePublisher"
classname="com.ibm.team.build.ant.task.FilePublisherTask" />
<taskdef name="jdtCompileLogPublisher"
classname="com.ibm.team.build.ant.task.JdtCompileLogPublisherTask" />
<taskdef name="junitLogPublisher"
classname="com.ibm.team.build.ant.task.JUnitLogPublisherTask" />
<taskdef name="linkPublisher"
classname="com.ibm.team.build.ant.task.LinkPublisherTask" />
<taskdef name="logPublisher"
classname="com.ibm.team.build.ant.task.LogPublisherTask" />
<taskdef name="startBuildActivity"
classname="com.ibm.team.build.ant.task.StartBuildActivityTask" />
<taskdef name="completeBuildActivity"
classname="com.ibm.team.build.ant.task.CompleteBuildActivityTask" />
</project>
Comments
Lakshmi Narasimhan T V
JAZZ DEVELOPER Jun 25 '19, 4:38 a.m.Richard Good
Jun 25 '19, 4:36 a.m.Richard Good
Jun 25 '19, 4:51 a.m.Richard Good
Jun 25 '19, 5:44 a.m.Richard Good
Jun 25 '19, 7:33 a.m.Sridevi Sangaiah
JAZZ DEVELOPER Jun 25 '19, 11:42 p.m.Richard Good
Jun 26 '19, 2:08 a.m.