I am trying to create a pipeline on jenkins which takes the code from a svn repository , builds it (using MSBuild) , tests it , creates a package from the build artifacts (using Maven) and then commits this package to another svn repository which belongs to another company.
This commit must have a specific commit message format which includes :
1- a short text
2- the url of our repository
3- the revision of some specific dlls what we used to build the solution
So as an example :
#Automatic Package Update
------
src_svn_url = "the source code URL"
src_svn_rev = 33568 , dll1 = 4654 , dll2 = 7657 , .....
------
I did some research and found out that it can be done through the pre-commit hooks. Are we able to make this pre-commit hook extract the revision number of different dlls inside my repo and write them automatically in the commit message every time we are committing? The goal for us is to know using which revision of the dlls , we produced the mentioned package.
This is not a task of any commit hook script.
You can run the svnversion command in your pipeline to get the revision number and use it to create a commit log message for your new commit into another repository.
For example, you can create the log message in a dedicated file log-message.txt with all the necessary information and then use the svn commit -F log-message.txt command to use the file's contents as the log message.
Related
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.
I have access to a project on SVN server and need to debug and understand the project. I exported the project as to ensure no changes affect the production or most recent updated version. But I cannot successfully run the ANT build as it looks for the jar files on the SVN server.
Can the project not run locally like this with my machine able to ping the server? I am familiar with MAVEN but not ANT so not sure if the checkout plays an important part in this.
Since this is in version control, you can change things and see what happens.
For example, if you have the jar files in a different location, change the ant script and see if it works.
If you type
svn status
it tells you the status; svn st for short.
If you want to roll back
svn revert [filename]
will put the script back as it was.
You need to do a svn commit to send changes back to the server.
Don't be afraid to try things locally.
I am doing the following steps:
dotnet restore
dotnet publish
octopusDeploy: Push packages
The second step creates a 'published-app' folder and the third step is meant to take that and create a .zip file and send it to the Octopus server.
The third step is connecting to the Octopus server but gives the error:
Running command: octo.exe push --server http://server.com/ --apikey SECRET
Pushing packages to Octopus server
Please specify a package to push
I am following this https://stackoverflow.com/a/38927027 so my third step has:
%teamcity.build.workingDir%/published-app/**/* => App.zip
Any ideas why the zip file is not being created?
Not sure if you ever got this working for yourself, however just in case it helps anyone we recently came across the same issue deploying an AspNetCore 2.0 web application running on net471 being built by TeamCity 2017.1.4 (build 47070).
After some tinkering I noticed that the "OctopusDeploy: Create and Push Packages" build step ran at our git checkout root directory, so I ending up having to use the following values for the "Package path patterns"
%ProjectDirectory%/published-app/**/* => %ProjectName%.%GitVersion.NuGetVersion%.zip
NB: %ProjectDirectory%, %ProjectName% and %GitVersion.NuGetVersion% are build parameters we have manually defined elsewhere in the build process that TeamCity can replace. %ProjectDirectory% is simply the application's source directory relative to the root of the git checkout i.e. WebApplication1 so the full path would be <full checkout path>/WebApplication1
Another gotcha that we experienced was that at the time of writing the combination of TeamCity and octo.exe (from Octopus.TeamCity v4.15.10) didn't like creating nupkg files, so make sure you try to produce a ".zip" file. In the error instances we would receive the following error:
Error from Octo.exe: Cannot run program "C:\BuildAgent\temp\buildTmp\octo-temp\3.0\octo.exe" (in directory "C:\BuildAgent\work\4e62985fa616fa1f"): CreateProcess error=206, The filename or extension is too long
Since GitLab 7.6, or thereabouts, there is a new option to use TeamCity directly from GitLab projects. In the setup there is this message:
The build configuration in Teamcity must use the build format number
%build.vcs.number% you will also want to configure monitoring of all
branches so merge requests build, that setting is in the vsc root
advanced settings.
I'm not sure how this works. Lets say I have a repository Foo.
I have setup a build on TeamCity to listen to Foo with branch specification: +:refs/pull/*/merge
I then fork Foo in gitlab as FooFork, make a change, then request a merge FooFork -> Foo.
But nothing happens to test this merge, which is what I was expecting GitLab to do. If I accept the merge than the build server jumps into action (immediately) and builds twice (master and /ref/master).
I've also set the build configuration to use exactly: %build.vcs.number% as the build number as prescribed, but gitlab doesn't seem to give me any information about the build result.
So I'm a bit confused really as to what exactly this GitLab -> TeamCity integration is supposed to do and whether I'm doing wrong.
I'm currently running GitLab 7.9 and TeamCity 8.1.4
Update:
Seems this use case was not supported prior to version 8 - https://github.com/gitlabhq/gitlabhq/issues/7240
I'm running GitLab 8.0.2 and TeamCity 9.1.1 and am able to run CI builds on branches and merge requests.
I trigger CI builds for specific branches by setting a VCS trigger together with the branch specification +:refs/heads/(xyz*) where xyz is the string for our ticket system prefix since all active branches need to be named after an entry in our issue tracker.
I trigger builds for merge requests via the branch specification +:refs/(merge-requests/*)
Everything works as as expected and lets us know the status of all feature / bug branches and merge requests automatically.
Thanks to Rob's comment linking to the GitLab 8 release notes entry on the merge request spec.
Same problem here. There might be another way, I'm evaluating right now. Since there's no direct way of getting the merged state from the target MR, you have to build it on your own:
IMO there's the following todos
1.) init a bare repo $ git init
2.) add your target repo $ git remote add origin git#your-repo:<origin.group>/<origin.repo>.git
3.) add the remote/feature/to-merge's $ git remote add target git#your-repo:<feature.group>/<feature.repo>.git
4.) checkout your feature branch $ git checkout -b <feature.branch> feature/<feature.branch>
5.) checkout your original branch $ git checkout -b <origin.branch> origin/<origin.branch>
6.) Rebase feature into your original branch $ git rebase <feature.branch>
As stated here [1], GitLab-CE can fire an event on creation of a merge-request,
so all you have to do is building some meta, that can evaluate the WebHooks.
[1] http://doc.gitlab.com/ce/web_hooks/web_hooks.html#merge-request-events
I would to run buildr on my svn repository - to build the files from \src\main\java in the subversion repository with username and password and save it to anther location on my disc.
How can I do it?
if i understand your question correctly, you are trying to setup a contiuous build system. checking out source code is the responsibility of your CI system. it would poll your svn, git or whatever cvs you use for changes and then build it on the configuration you provide.
a free build-server is jenkins (aka hudson). if you want a hosted solution you can go for travis-ci (it's free). or something expensive like atlassian bamboo.
You will have to write an Ruby build script - that when you execute will:
Checkout the source
do the 'buildr'
Commit the built file(s)
http://www.markdeepwell.com/2010/06/ruby-subversion-bindings/
http://blog.carlossanchez.eu/2009/08/18/using-subversion-ruby-bindings/
the easiest way is run external svn commands
task :checkout do
system 'svn checkout ..'
end