How to get ${buildNumber} in TFS with Maven? - maven

I need to add the buildNumber in my generated manifest file with Maven. We use TFS(Team Foundation Server) as our repository. Is there any way to access it?
Below link explain the how get build number with Git, SVN or Mercuria.
http://www.yegor256.com/2014/07/03/how-to-read-manifest-mf.html
I also need the same thing with TFS?

You can use ${env.TF_BUILD_BUILDNUMBER} environment variable to get TFS build number.
Please have a check on this link: https://blogs.blackmarble.co.uk/blogs/rfennell/post/2014/12/16/Setting-a-build-version-in-a-JAR-file-from-TFS-build.aspx

I think the correct variable number is env.TFS_CHANGESET or just TFS_CHANGESET. It worked for me.

Predefined variables in TFS:
Build.SourceVersion - Git: The commit ID.
BUILD_SOURCEVERSION - TFVC: the changeset.
A list of all variables here:
https://www.visualstudio.com/en-us/docs/build/define/variables

Related

Jenkins without Git Repository

I have a source code using which I want to test some processes through Jenkins.For that I've installed Jenkins and plugins as well. But I do not have internet access to my machine so I have my source code in a local folder instead of Git.
Please help me to configure Jenkins without git.
Thanks a ton in advance.
in the build steps, you can do something like
cd C:\users\user\Documents\Projects\
// build here
if you're in a different directory, you need to do:
cd D:\Projects
D:
// build here
But deleting the workspace option won't work now. since your artifacts will be stored in the current directory and the workspace is a different directory. you can add an additional step, in this case, to clean up things or you can change the workspace from the advanced option in the general tab.

maven directory not found in Jenkins?

I am doing auto deployment of Java Application using Maven and Jenkins, but it is getting failed.Here is the console output:
I have set the environment varaibles and also downloaded and configure all the required plugins. Need help to solve this issue.
Thanks
First of all: Please copy/paste messages instead of using images.
Secondly, the message said that you probably misconfigured the directory for the settings.xml. The settings.xml is usually in the directory .m2 in the user directory, but it can also be supplied from somewhere else.

how to force maven to update local repo

I compiled a jar file in one project so it can be consumed in the 2nd one. I can see the jar file in .m2 folder. But in the 2nd project it complains about artifact not found.
I guess I have to force maven to update indices/cache something but don't know what exactly. Any tip, thanks.
Update: thanks for all good suggestions.
Turns out that the maven plugin (of IntelliJ) in the second project doesn't update its index. I use command line it compiled ok.
try using -U (aka --update-snapshots) when you run maven
And make sure the dependency definition is correct
You can also use this command on the command line:
mvn dependency:purge-local-repository clean install
If you are installing into local repository, there is no special index/cache update needed.
Make sure that:
You have installed the first artifact in your local repository properly. Simply copying the file to .m2 may not work as expected. Make sure you install it by mvn install
The dependency in 2nd project is setup correctly. Check on any typo in groupId/artifactId/version, or unmatched artifact type/classifier.
Even though this is an old question, I 've stumbled upon this issue multiple times and until now never figured out how to fix it. The update maven indices is a term coined by IntelliJ, and if it still doesn't work after you've compiled the first project, chances are that you are using 2 different maven installations.
Press CTRL+Shift+A to open up the Actions menu. Type Maven and go to Maven Settings. Check the Home Directory to use the same maven as you use via the command line
Click settings and search for "Repositories", then select the local repo and click "Update". That's all. This action meets my need.
If you are struggling with authenticating to a site, and Maven is caching the results, simply removing the meta-data about the site from the meta-data stash will force Maven to revisit the site.
gvim <local-git-repository>/commons-codec/resolver-status.properties

How to index a Maven repo without Nexus/Artifactory/etc?

I run my own little Maven repo for some open source. I have no dedicated server so I use a Google code repository, deploy to file system and then commit and push. Works perfect for me.
But some Maven tools are looking for a nexus-maven-repository-index.properties and the index (in GZ). I would like to generate this index to
get rid of the warning that it's not here
Maven doesn't try the repo for artefacts that are not there.
How can I do that? Is there a tool (Java main) that is able to generate an index? Also tips how to use the proper Nexus Jars with a little commandline tool are welcome.
I came across this post while I was searching for a solution to add a local repository to my Maven project using IntelliJ Idea.
Since Sonatype changed their paths and reorganized the downloads since the last post, here is an updated step-by-step tutorial to get your repository indexed for use with IntelliJ Idea:
Download the latest stand-alone indexer from here.
Extract it somewhere and go into this directory
From the console, run this command: export REPODIR=/path/to/your/local/repo/ && java org.sonatype.nexus.index.cli.NexusIndexerCli -r $REPODIR -i $REPODIR/.index -d $REPODIR/.index -n localrepo
In the directory .index within the repository directory, some files will be created including the file "nexus-maven-repository-index.gz" which is the file IntelliJ looks out for.
You can use the Maven Indexer CLI to product the index directly, but why bother hosting your own repo when OSS projects can use a hosted one for free?
http://nexus.sonatype.org/oss-repository-hosting.html
I was looking at maven indexer... but I am not sure what for is the last parameter indexDir in the method:
public RepositoryIndexer createRepositoryIndexer(String repositoryId,
File repositoryBasedir,
File indexDir)
is it like starting point in the repositoryBasedir?

How do I specifiy or override the file and path name for ftp publish location after a hudson build?

I am using hudson and the "Publish artifacts to FTP" option. It makes up its own directory based on the date and time of the build. I would like to override that with a fixed name/location. How can I do that? Is it possible?
What version of the FTP Publisher plugin are you using? I just installed the 1.0 version on Hudson 1.361, and in that version I can control the path by selecting the Flatten files option in the job configuration. Timestamp directories can also be disabled (that was the default).
That would solve path control. For the filename control, there doesn't seem to be a way to rename the file. You will either have to create an artifact with the right name during the build, or use some other tool for the ftp upload.
Edit: For example, the Post Build task, that can run arbitrary shell commands based on the result of the build.

Resources