The workspace might no longer contain the correct revision at the time the 
promotion runs. 

Also, the BUILD_NUMBER might not be available as a variable. 

I really don't know. 

I'm doing the same and the only way I got it working was to trigger another 
job. This job uses copy artifacts plugin to get a file that contains the git 
revision of the build that passes. It can get it from last promoted build. This 
job then checks out the required version and allows git plugin to publish the 
tag. It works, it just needs this one extra job to do it. 

-- Sami

Maarten <[email protected]> kirjoitti 6.2.2012 kello 18.12:

> Hi jenkinytes,
> I've been struggling with pushing a build a git tag when a build is
> promoted. I've set up a build to be promoted when it's downstream
> build succeeds, and then as the (only) promotion action I've set the
> Git Publisher to push a (newly created) tag with certain name to the
> repository that I checked out from in the first place. The config is
> like this:
> 
> <?xml version='1.0' encoding='utf-8'?>
> <hudson.plugins.promoted__builds.PromotionProcess>
>  <keepDependencies>false</keepDependencies>
>  <properties />
>  <scm class="hudson.scm.NullSCM" />
>  <canRoam>true</canRoam>
>  <disabled>false</disabled>
>  <blockBuildWhenDownstreamBuilding>false</
> blockBuildWhenDownstreamBuilding>
>  <blockBuildWhenUpstreamBuilding>false</
> blockBuildWhenUpstreamBuilding>
>  <triggers class="vector" />
>  <concurrentBuild>false</concurrentBuild>
>  <conditions>
> 
> <hudson.plugins.promoted__builds.conditions.DownstreamPassCondition>
>      <jobs>TestJob - test </jobs>
>      <evenIfUnstable>false</evenIfUnstable>
>    </
> hudson.plugins.promoted__builds.conditions.DownstreamPassCondition>
>  </conditions>
>  <icon>star-gold</icon>
>  <buildSteps>
>    <hudson.plugins.git.GitPublisher>
>      <configVersion>2</configVersion>
>      <pushMerge>false</pushMerge>
>      <pushOnlyIfSuccess>false</pushOnlyIfSuccess>
>      <tagsToPush>
>        <hudson.plugins.git.GitPublisher_-TagToPush>
>          <targetRepoName>origin</targetRepoName>
>          <tagName>build-${BUILD_NUMBER}</tagName>
>          <createTag>true</createTag>
>        </hudson.plugins.git.GitPublisher_-TagToPush>
>      </tagsToPush>
>    </hudson.plugins.git.GitPublisher>
>  </buildSteps>
> </hudson.plugins.promoted__builds.PromotionProcess>
> 
> However, when the build is promoted, the promotion action fails with
> this messagen:
> 
> Legacy code started this job.  No cause information is available
> Building on master in workspace /home/java/.jenkins/jobs/TestJob/
> workspace
> Promoting TestJob - Build #47
> failed build hudson.plugins.git.GitPublisher@3d9f2b SUCCESS
> Finished: FAILURE
> 
> Beside that fact that it's confusing (how can it bet successfull and
> still fail), I also can't figure out what the problem is, because
> there is no stacktrace or anything. I know the config is good because
> exactly the same setup does work if you configure it as a normal, post-
> buid build publiser.
> 
> I'm using Jenkins 1.449 and the Promoted Builder plugin v.2.4
> Ayone know what's going on? Any help would be much appreciated.
> Regards,
> Maarten

Reply via email to