Following Jenkins documentation jenkins docs
I can use the POM_VERSION environment variable to take the current version from the pom file.
But for some reason the POM_VERSION environment variable is not being refreshed from build to build. for example:
I changed the version number manually but the build number that exported was the last from the previous build.
From my python script:
print 'Current version is ' + os.environ['POM_VERSION']
which gives the following log Current version is 0.1.5 which is clearly wrong because i changed it. you can further see it in my maven versions goal output:
[INFO]
[INFO] --- versions-maven-plugin:2.1:set (default-cli) # ep-reporter ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /var/lib/jenkins/jobs/exchange-planner- reporter/workspace
[INFO] Processing com.exelate:ep-reporter
[INFO] Updating project com.company:ep-reporter
[INFO] from version 0.1.8 to 0.1.6
Props: {project.version=0.1.6, project.artifactId=ep-reporter, project.groupId=com.company}
note that it went from 0.1.5 because i have a script that advances it. but maven clearly states that its changing it from 0.1.8 to 0.1.6 which is not what POM_VERSION says
Thanks.
That environment variable is set at the time Jenkins first reads your POM file. You are clearly changing it during the build.
If you are changing it during the build, you know what you are changing to, and you should use the same mechanism to display it later.
I had the same problem and I resolved it by setting "Check-out Strategy" option to "Always checkout a fresh copy" in Source Code Management section.
Related
Hello Allure generators,
I'm trying to make Allure accessible to our testers in the company. I've installed Allure 2 through Scoop in the server and I'm able to run the cmd script: "allure serve" and see the results. So far so good. Now, my basic thought for solution is : run a "Post build actions" with a "Post build tasks" plugin with the allure serve command. The result is not good:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.801 s
[INFO] Finished at: 2018-06-25T11:08:28Z
[INFO] ------------------------------------------------------------------------
Performing Post build task...
Match found for : : True
Logical operation result is TRUE
Running script : cd C:\Projects\CarambolaClientTest2\target
allure serve
[Suite_runner] $ cmd /c call C:\Windows\TEMP\jenkins6058556997605873748.bat
C:\Program Files (x86)\Jenkins\workspace\Suite_runner>cd C:\Projects\CarambolaClientTest2\target
C:\Projects\CarambolaClientTest2\target>allure serve
'allure' is not recognized as an internal or external command,
operable program or batch file.
C:\Projects\CarambolaClientTest2\target>exit 9009
POST BUILD TASK : FAILURE
How can it be that "'allure' is not recognized.." ? It recognized it through the cmd (I've added it to the Environment variables of the machine and also to the environment variables in Jenkins configuration under Global properties).
I've also tried:
Create a Batch file with the script and run it in the post build
task (got the same result).
Add the Allure Plugin- but that's a
whole new problem- I'm getting an empty report.
Create new Job that only runs a "Windows batch command" with the allure serve, and it is running "Down stream" after the main Job runs (its the 2nd
project). Getting the same result.
Any ideas?
Thanks
You don't have allure executable in your PATH. Try to reload jenkins slave (or master) to see changes if you've added it to PATH before.
Also you can make Jenkins install allure automatically - find the a plugin for that
I have a multi-component maven project in Jenkins. This project has a Send Files over FTP Post-Build step. I have set my mvn goals to build just my desired component; not all of them:
clean install -pl component-x,component-y -P develop -X
All the dependencies in my project are built successfully;
[INFO] component-x ............................ SUCCESS [ 5.026 s]
[INFO] component-y ............................ SUCCESS [ 16.912 s]
but the Jenkins says:
FTP: Current build result is [NOT_BUILT], not going to run.
EDIT 1:
Yes, I have read this issue. People suggestions include:
Do it manually.
Use Execute Shell instead.
But there were no solution for How to do it manually.
BTW I have an FTP server which I want to put files on; it's not possible for me to use Execute Shell.
Looks like because of this bug https://issues.jenkins-ci.org/browse/JENKINS-16240
Either you can set the status to success manually or use execute shell for ftp instead of the plugin.
You can run a post build groovy script manager.buildSuccess()
See here
The problem is, that the Publish over FTP plugin checks if the build was successful. Unstable is accepted, too, but NOT_BUILT isn't. If the build is not considered successful, the plugin refuses to run.
It is arguable, if that is an expected behavior. The user might want to transfer files, even if the build was not successful. Besides, the NOT_BUILT obviously refers only to the last build step, not to the overall result which is still SUCCESS.
There is an issue filed under JENKINS-55816.
I've created a patch that does not check for the build result which can be downloaded from here (use at your own risk, with no warranty whatsoever).
We have been executing sonar analysis successfully with SQ-4.5.4 version with no issues. Suddenly since couple days our sonar analysis build is failing with below error message:
It is not indexing any source file even though it has found them. We have made no changes in our pom.xml or project structure. I am not sure why it is adding "build/sonar" to base directory path that I have mentioned in pom.xml for project base directory. I tried giving relative path too but still issue is reproducible.
[INFO] [14:03:23.298] Base dir: /opt/customer/ci_workspace/sonar/10.1.0/TN/build/sonar
[INFO] [14:03:23.302] Source encoding: ISO-8859-1, default locale: en_US
[INFO] [14:03:23.304] Index files
[WARN] [14:03:24.008] File '/opt/customer/ci_workspace/sonar/10.1.0/TN/access/Application/src/com/panther/ph/access/persistence/cocobase/AccessBP.java' is ignored. It is not located in module basedir '/opt/customer/ci_workspace/sonar/10.1.0/TN/build/sonar'.
I have mentioned below property in my pom.xml
"/opt/customer/ci_workspace/sonar/10.1.0/TN
../../access/Application/src"
The base directory is where your POM is located and your analysis launched.
The problem is that in the POM, you are referring to a source folder that is not located in a sub-folder of the base directory. This is not supported in SonarQube - and this is actually not a standard structure for source code.
#Fabrice: The issue was someone had made some changes in repository which made our sonar-maven-plugin degrade to 2.0 version from 2.6 due to which it has failed.
#Everyone: If you are facing similar issue please check your sonar-maven-plugin is at least 2.6 version.
I have a project that contains javascript files in src/main/webapp/js. In order to analyze these, I am executing the following:
mvn install org.codehaus.sonar:sonar-maven-plugin:3.5:sonar -Dsonar.branch=js -Dsonar.language=js -Dsonar.sources=src/main/webapp/js -Dsonar.login=sonar -Dsonar.password=sonar
I have also attempting this with: -Dsonar.importSources=true
When I execute this, I get a build success. However, when I look at the js project I created, it contains no data. When I look at the logs, I see this which leads me to believe that the sonar.sources property is not being read.
[INFO] [17:38:42.273] Base dir: /home/mw-sandbox/.jenkins/jobs/ssi-wdf-re/workspace
[INFO] [17:38:42.273] Working dir: /home/mw-sandbox/.jenkins/jobs/ssi-wdf-re/workspace/target/sonar
[INFO] [17:38:42.273] Source dirs: /home/mw-sandbox/.jenkins/jobs/ssi-wdf-re/workspace/src/main/java, /home/mw-sandbox/.jenkins/jobs/ssi-wdf-re/workspace/target/generated-sources/wsimport
[INFO] [17:38:42.273] Test dirs: /home/mw-sandbox/.jenkins/jobs/ssi-wdf-re/workspace/src/test/java
[INFO] [17:38:42.273] Binary dirs: /home/mw-sandbox/.jenkins/jobs/ssi-wdf-re/workspace/target/classes
[INFO] [17:38:42.273] Source encoding: UTF-8, default locale: en_US
Can anyone suggest a solution for this?
For now, it is not possible to use properties such as "sonar.sources" when the analysis is triggered with Maven. See http://docs.codehaus.org/display/SONAR/Analysis+Parameters. But it should be soon. See http://jira.codehaus.org/browse/SONAR-4536.
So, you can work with Maven profiles to override source directories.
A work-around have been found in this post :
Empty metrics in sonar for web and javascript projects
It is a bit messy with the maven profiles, but I tried it, it does the job...
I'm using the Maven plugin was6-maven-plugin to deploy to websphere. When installing an application, there's a configuration value named "updateExisting" that should be false if I am installing a new application, and true if I am updating an existing application. I don't like having to manually toggle this value if I am fresh-installing/updating the application.
The way I see it, I can either add an uninstallApp goal to always uninstall the application before installing it, but this seems a rather silly way to do it.
I've noticed that this plugin also has a goal wsListApps that outputs all applications installed on the server. The output looks like this:
[INFO] [wsadmin] WASX7209I: Connected to process "server1" on node 1234Node02 using SOAP connector; The type of process is: UnManagedProcess
[INFO] [wsadmin] DefaultApplication
[INFO] [wsadmin] IBMUTC
[INFO] [wsadmin] MyApplicationEAR
[INFO] [wsadmin] ivtApp
[INFO] [wsadmin] query
Is it possible for Maven to scan this output for the string "MyApplicationEAR" and set "updateExisting" to "true" if it is found, and leave it "false" otherwise?
What you need is to be able to update a maven property during the life-cycle, before the phase binded with your was6-maven-plugin. (and using this property as a value for <updateExisting>)
Unfortunately, maven properties are static and cannot be changed at runtime. So at first sight it's impossible to do.
But, there is a plugin : properties-maven-plugin you can use to define new properties at runtime. The value of the property can be defined by a groovy script. Now the question is more about how can you write a groovy script telling if your app is already there or not.
Honestly, I don't know if it's a good idea to use it. I think running the uninstall goal everytime with failOnError set to false is probably the simplest way (and so probably the best, but maybe I am missing something ?)