sbt build on CloudBees gives "Name: No value provided for Name" - jenkins

I'm trying to set up an sbt build on a CloudBees-hosted Jenkins server. The repository is stored in GitHub, and Jenkins is pulling the repository fine as I can see all the code in the workspace.
However, when I try to run the build I get the following output:
...
Seen branch in repository origin/master
Seen 2 remote branches
Commencing build of Revision 763eecd49a522a50e53c6f24e40e5f2e984d3737 (origin/HEAD, origin/master)
Checking out Revision 763eecd49a522a50e53c6f24e40e5f2e984d3737 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here
[ProjectName] $ java -Dsbt.log.noformat=true -jar /opt/sbt/sbt-launch-0.7.4.jar clean test
Name: No value provided for Name
Build step 'Build using sbt' changed build result to FAILURE
Build step 'Build using sbt' marked build as failure
Finished: FAILURE
The build runs fine on two other machines, even when run using an equivalent command line to the one Jenkins is using. The project itself is a multi-project build with Play Framework.

THis is probably due to having the incorrect version of the sbt-launch jar in your global config's sbt section. If you update it to say /opt/sbt/sbt-launch-0.13.0.jar that should resolve your problem

Related

Jenkins multibranch: error MC1000: Unknown build error

Currently, I have a Jenkins multibranch pipeline. It clones my git repo and builds the solution via a Jenkinsfile. The Jenkinsfile has 5 stages:
checkout scm
restore nugets (using nuget.exe)
Build Debug config of solution using msbuild from command line:
--> bat "\"${tool 'VS2017'}\"\MsBuild.exe %WORKSPACE%\mysolution.sln /p:Configuration=Debug /p:Platform=\"x64\""
Build Release config of solution using msbuild from command line (same cmd line as above)
Build Custom config of solution using msbuild from command line (same cmd line as above)
So right now this does three builds back to back using MSBuild. Intermittently, one of the the builds fail. The error I get:
(MarkupCompilePass1 target) ->
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error, 'Object reference not set to an instance of an object.'
Not sure why this happens. But as mentioned it only happens sometimes. Other times the build passes successfully. I have a feeling this has to do with an update as this never hapened before. Either with the MSBuild (VS 2017) or a Windows Update (Server 2016).
Any help on this greatly appreciated

Dimensions plugin for Jenkins load any build artifacts to dimensions set request id

In my Jenkins build job I pull java code from Gitlab and build on Jenkins using Ant build script (build.xml). A .zip file outcome of the build.
I am trying to upload build artifacts (zip file) to Dimensions CM using Dimensions plugin for Jenkins using 'load any build artifacts to dimensions' as a post build action. Dimension is rejecting the artifact due to lack of the request id for it attach this artifact in Dimensions.
The plugin documentation says to "If you wish to specify a request to save these changes against, then you should set a project default request using SCWS or use DM_TARGET_REQUEST"
I am getting this error:
START ======= Started by user Ahmad, Ershad [EnvInject] -
Loading node environment variables. Building on master in
workspace /opt/wss/stg/jenkins/DimensionsUpload1 [DIMENSIONS]
Calculating changes for directory
'DM_TARGET_REQUEST=PCMTPROJPROJ_SMR_82'... [DimensionsUpload1] $
/bin/sh -xe
/opt/wss/stg/apache-tomcat-6.0.43/temp/hudson7507543782532160733.sh
+ cd /opt/wss/stg/jenkins/DimensionsUpload1
+ ls -ltr total 138484
-rw-r-----. 1 webdev webdev 141800254 Feb 16 08:11 BuildArtifact.1.0.zip [DIMENSIONS] Running checkin on
master... [DIMENSIONS] Running build in
'/opt/wss/stg/jenkins/DimensionsUpload1'... [DIMENSIONS] Scanning
workspace for files to be saved into Dimensions... [DIMENSIONS]
Running Ant pattern scanner... [DIMENSIONS] Found 1 file(s) to
check in... [DIMENSIONS] Loading files into Dimensions project
"PCMTPROJ:RELSTREAM"... FATAL: Unable to run checkin callout
(DimensionsRuntimeException: Upload files (DimensionsRuntimeException:
Dimensions command 'UPLOAD
/USER_FILELIST="/opt/wss/stg/apache-tomcat-6.0.43/temp/dmCm15188000765706781907912904279764.tmp"
/WORKSET="PCMTPROJ:RELSTREAM" /COMMENT="Build artifacts delivered by
Jenkins for job 'DEVOPS_PCMTPROJ_DmUpload' - build 68"
/USER_DIRECTORY="/opt/wss/stg/jenkins/DimensionsUpload1"' failed
(DimensionsRuntimeException: Using Project 'PCMTPROJ:RELSTREAM'. Using
'/opt/wss/stg/jenkins/DimensionsUpload1/' as the Project work
area. Scanning repository: 0.00 sec Scanning local work
area: 0.00 sec Creating new item revision for
'/opt/wss/stg/jenkins/DimensionsUpload1/BuildArtifact.1.0.zip'
COR0005162E Error: To create a new Item revision of type PROD_CODE you must specify a valid request COR0006384E Error: Failed to
create Item for
'/opt/wss/stg/jenkins/DimensionsUpload1/BuildArtifact.1.0.zip'
Warning: There were errors while uploading files from the specified
network node. Please check the upload log. Updating files: 2.57
sec Uploading Project: 2.58 sec ))) Build step 'Load
any build artifacts into the Dimensions repository' changed build
result to FAILURE Build step 'Load any build artifacts into the
Dimensions repository' marked build as failure Finished:
FAILURE
=======END
I have tried using the export command in shell but it doesn't work:
cd /opt/wss/stg/jenkins/DimensionsUpload1
ls -ltr
export $ITEM_TYPE PROD_CODE
export $DM_TARGET_REQUEST PCM_SMR_82
I was able to resolve this using the below option
Click on configure in your build job
[Check box] This build is parameterized (see pic below)

Error in Executing Jobs on Slave In Jenkins

I have Master Slave configuration under Jenkins.I wanted to run a job on the slave system under Jenkins I order to do that I have copied the required scripts and files But I have been getting the following error
Started by user anonymous
[EnvInject] - Loading node environment variables.
Building remotely on MySlave in workspace C:\Users\prathamesh.n\workspace\MasterSlave
FATAL: Cannot find executable from the chosen Ant installation "apache-ant-1.9.4"
Build step 'Invoke Ant' marked build as failure
Archiving artifacts
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level C:\Users\sudharshan.r\workspace\Ant\exec\reports\Test 1 to C:\Users\sudharshan.r.jenkins\jobs\Project 11\htmlreports\HTML_Report
ERROR: Specified HTML directory 'C:\Users\sudharshan.r\workspace\Ant\exec\reports\Test 1' does not exist.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: C:/Users/sudharshan.r/workspace/Ant/exec/reports/Test 1/testng-results.xml
Did not find any matching files.
[BFA] Scanning build for known causes...
[BFA] Done. 0s
Finished: FAILURE
need help on executing ant on slave
Click on Jenkins - > Manage Jenkins -> configure system -> Under Ant, define your installer and then in your job select that ant configuration.
Whats your configuration in your build? Default or let's assume my 1.9.
Now in "configure jenkins": Add a specific ant e.g. with name my 1.9.
easiest way is automatic installation and installation from Apache
if you don't want to do this: uncheck automatic installation and give your path were you installed ant in the field: ANT_HOME

Jenkins gerrit trigger not fetching my change while building

I have configured jenkins with gerrit trigger plugin to validate every commit we push to gerrit.
I am expecting this trigger to include my latest change with original repo and make a build.
But, it is cloning only repo project and compiling without my change.
Below is my configuration settings for gerrit trigger in jenkins.
Refspec: $GERRIT_REFSPEC
Branches to build: $GERRIT_BRANCH
Build trigger: Gerrit event
Trigger on: patch set created
Gerrit project: added project and branch
Below is the build output message
Triggered by Gerrit: http://ci-test1/22
Building on master in workspace /var/lib/jenkins/jobs/Build_Adserver_4.7/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Build_Adserver_4.7/workspace - hudson.remoting.LocalChannel#733aee56
Using strategy: Default
Last Built Revision: Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
Fetching changes from 1 remote Git repository
Fetching upstream changes from abc
Commencing build of Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
Checking out Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
[workspace] $ /bin/sh -xe /tmp/hudson1375188638196718521.sh
+ echo 'Started Build'
Started Build
+ echo ..................
..................
+ echo 'Build Finished'
Build Finished
Finished: SUCCESS
Here 701a75ef38aa191ac1b806c48e6b3451671888f6 is HEAD of repo branch and 8cbda558adcad4fb7eb714e0b3fb98a6fbf5811c is the SHA-id of my latest change trigged the build.
I verified from jenkins workspace also, it doesn't include my change.
sorry if I am missing any information to mention. Please let me know
please help me if I am missing anything here.
Using Jenkins 1.532.2 Git Client Plugin 1.6.2 Git Plugin 2.0.1 Git Trigger 2.11.0
Here are the steps for configuring the Gerrit Trigger (from memory, hopefully all works fine):
Install the plugin(s) "Gerrit Trigger", "Git Plugin" and "Git Client Plugin"
In the main jenkins config (HOME->Manage Jenkins), click on Gerrit Trigger.
Create the server and configure it. Use "Test Connection" to be sure it works.
At the end, under "Control" press "start" (No idea what that does or if it's actually needed, but I did that).
Go to your project's config (MYPROJECT->Configure)
Check "Gerrit event" under "Build Triggers"
In the newly added menu, select your server, your triggers, etc.
For Gerrit Project I used "Plain" with "MYPROJECT" as pattern
For Branch, I used "Path" and "**" as pattern (builds all branches)
Under "Source Code Management" (up from triggers in my UI), click on "Git"
Set the Repository URL, here $USER matches for me, but otherwise write the correct user $GERRIT_SCHEME://$USER#$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT
Specify a branch: $GERRIT_BRANCH
Under "Repositories" on the right, click Advanced, for "Refspec" enter $GERRIT_REFSPEC
Click Add right below, and select "Strategy for choosing what to build"
Select "Gerrit Trigger"
Not very intuitive but it should work. I suggest making sure the correct SHA1 Ids are being built.
If run into Error stderr: fatal: Couldn't find remote ref $GERRIT_REFSPEC
You have to change the Choosing Strategy to Gerrit Trigger
Go to the configuration page of your job and then click on the 2nd Advanced button under the git section. Almost at the bottom there is a Choosing Strategy that you will need to change to Gerrit Trigger
This will cause Git to fetch the correct version for your build
Fixing small issues in Lewis answer, change the values to the following to ensure the latest SHA1 is built.
branch: $GERRIT_REFSPEC
REFSPEC: $GERRIT_REFSPEC:$GERRIT_REFSPEC
I am using Jenkins 2.15 and faced the Issue and got resolved with following settings.
In Git Advances add Refspec : $GERRIT_REFSPEC
Branches to build : $GERRIT_BRANCH.
In Addititional behaviors section select Strategy for choosing what to build and select gerrit Trigger.

Make jenkins auto build one a day but build only when there are source code changed

I have problem in configure jenkins to auto build and deploy java project. I want to build and deploy once a day. However this build only there are changes during the day. IF there is no changes, I don't want jenkins to auto build and deploy.
Note: that I used gitlab as source code management.
Can you help me with this configuration.?
Firstly, you should configure the Git SCM section at the top of the job config page to point to your GitLab repository.
Then you can use the built-in "Poll SCM" build trigger — this will periodically check whether your source code repository has changed — and if it has, a build of this job will be started.
If the repository has not changed since the last build, then no build will be started.
You can configure this trigger — whether using a cron-like syntax, or a shortcut like #daily or #midnight — so that Jenkins only checks the source repository once a day.
Additionally, you should make sure that the "ignore post-commit hooks" option is enabled. If you're using webhooks from your Git repository to start Jenkins jobs whenever a commit occurs, this option prevents your once-per-day job from being triggered for every Git commit.
Here's the detail document: "Jenkins CI integration"
http://doc.gitlab.com/ee/integration/jenkins.html
Update to match your comment.
You don't want to trigger the Jenkins build via webhook. It's ok.
You want to check the code change 1 time a day.
Example on Linux, build at 6:00 AM if there's any code change.
Install
https://wiki.jenkins-ci.org/display/JENKINS/PostBuildScript+Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Text-finder+Plugin
Build Triggers
Build periodically: 0 6 * * *
Execute shell
Like this
SINCE=`curl http://192.168.0.1:8080/job/MyJava/lastStableBuild/buildTimestamp?format=dd-MMM-yyyy`
cd /opt/code/myjava/
git log --pretty="%h - %s" --author=gitster --since=$SINCE --before=$SINCE --no-merges -- t/
Post Build actions
Post build task
Log text: commit
Operation: AND
Script: Your script to build your Java
Jenkins text finder
Also search the console output
Regular expression: Could not match
Unstable if found

Resources