How to get the revision number of a TeamCity artifact - teamcity

How do I find the TeamCity revision number of an artifact's last checkin? (NOT the lastest build number)

Teamcity populates a predefined parameter build.vcs.number.<VCS root ID> which holds the revision number of the check-in. See Predefined Build Parameters for more information.

From my understanding the configuration parameter "teamcity.build.id" is used as the artifact revision number.
On Linux environment, the build artifacts can be access from the location -
"/opt/TeamCity/data/system/artifacts/project.id/buildConfName/teamcity.build.id"
Cheers

Related

How to get latest artifact from artifactory?

I have artifacts in JFrog.
Example:
https://test.com/artifactory/users/data-config/1.0.0/user.json
https://test.com/artifactory/users/data-config/1.0.1/user.json
https://test.com/artifactory/users/data-config/2.0.0/user.json
Is there a way I can download the latest version using curl? Like in this case it will be
https://test.com/artifactory/users/data-config/2.0.0/user.json
Considering your comment that the files are not maven based, I assume it is deployed to a generic repository and irrespective of the file type, the only way to resolve the file via direct cURL is using the following command.
curl -u<USERNAME>:<PASSWORD> -O "http://<HOSTNAME>:<PORT>/artifactory/generic-repository/<TARGET_FILE_PATH>"
So, the target path name should be given completely when it is being resolved via direct download (API). i.e., The complete target file name manually.
However, for other package types such as a maven release or a snapshot, the available options are described here.
What are a few other additional options available?
Artifact Latest Version Search Based on Layout
, Artifact Latest Version Search Based on Properties

How I can access to a file saved in Gitlab CI/CD artifact in the next stages and increase it's version

I have a spring boot application and I deployed it in the first stage and now I have a jar file.
my question is how to access this jar file in the next stage and how I can run it.
second question is HOW can I increase its version number? for example jar file name is spring.0.0.1.jar and I want to increase version number after every push. is this possible?
First Question:
You can save the jar file as an artifact and access it in the second stages jobs' script area. For example
FirstJob:
stage: FirstStage
scrip:
- <your commands here>
artifacs:
paths:
- ./artifacts/myOutput.jar
Now your "myOutput.jar" is accessible in the artifacts folder for all following jobs. See here: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html
Second Question:
As far as I know there is no way of handing down variables between pipelines in GitLab CI so this would not be possible if I'm right. Since artifacts don't get added to the repository, previous artifacts are not available to following pipelines either. Yet, if I had to come up with a solution on the spot, I'd try:
Saving the version number somewhere accessible to every pipeline (cloud, repo)
git push every artifact to actually add it to the repository, then check file name and increment version number
using the GitLab CI release option. The CI can create a release object for you, maybe this could help as well. See here: https://docs.gitlab.com/ee/ci/yaml/README.html#release

How to pin revision number of Jenkins build?

I have a Jenkins multiphase job that
gets an update from version control (Subversion)
does a Maven build. Couldn't be more cut and dry.
The 1. above, svn update, does return a latest revision number. I would like to fetch that into 2. so that the build and its associated artifacts do have that number pinned to them, if any way possible in the artifact name itself but, if not, in the build history. Is there a way to do it and how (e.g. using the subversion or another plugin)?
I am using the buildnumber plugin to fetch the build number and generate a small text file that is contained inside my WAR artifacts, which makes it subsequently available via HTTP. But to see it, one must either first deploy the artifact or at least extract its contents. I would like it more readily visible in Jenkins.
You should take a look at How to get SVN revision number in Jenkins Workflow Plugin? - He solved the problem with:
def revision = 'svn info'.execute().in.text.split('\n').find { it.startsWith('Revision') }.split(':')[1].trim()
He's obviously using the latest Jenkins version, but if you're using one of the old Jenkins versions you can simply run the following command and parse the result to get the revision number you want:
svn info -r HEAD
BTW you can use a Jenkins constant too. In the browser you can open http://your-jenkins-host/env-vars.html/ and you will find a constant named SVN_REVISION. Each job build keep the SVN revision into that variable.

Pass/share parameter values between dependant builds in TeamCity

Setup: Build CD has has Artifact Dependency and Snapshot Dependency on Build CI. Build CI pulls from VCS root and generates artifacts for Build CD.
Problem: In Build CD I need %teamcity.build.branch% parameter, but it's not available, because it only uses artifacts and has no VCS Roots linked.
Question: Is there a way to pass parameters between dependant builds? (search results in the googles seem of topic)
Workaround 1: I can access %teamcity.build.branch% in Build CD if I link it to same VCS root Build CI is using, but I'd like to avoid having this link and Build CD unnecessarily pulling from VCS (build log shows it does this).
Workaround 2: I could write parameter to a file in Build CI and read from it in Build CD later. This is a hack and I would like to avoid it as well.
Absolutely. In CD, add a parameter called whatever, with value equal to %dep.Build_CI.teamcity.build.branch%. TeamCity will help you figure out the exact value thanks to its auto-suggestion/auto-completion, once you type %dep..

maven release prepare tagging incorrect revision number

Hy, I am using 3.2.5 maven.
I have a problem with releasing. I use the release:prepare to Tagging from trunk and create version without snapshot. The preapre run clean and verify by default after Transforming but I modified this setting to celan. So the prepapre goal dont create build.
I use release:perform to checkout from tag and build. I woudlike add manifest.mf with svn revision number to build.
This is ok but the revision number in build equal the revison number of Trunk.
For example: Tag revision = 7000 and Trunk revision=7001. When I make a build from tag it make revision number 7001.
I chechked the Tag manualy and create build with install and the revision number as soon as than perform.
I tagging manualy and create build with install and the revision number correct so the revision number eqaul the revision number of tag.
It visible the revision number of tag and trunk in svn. When revison number of tag 7000 but I get 7001 in build (tagging with prepare).
Can you help me?
Thank you!

Resources