Atlassian bamboo: Ant deploy task keeps failing - deployment

I have a deployment project setup via Atlassian bamboo.
The steps are being executed successfully until the Apache Ant task.
I don't know what is going wrong; if I execute the command on the server it works without any errors.
-bash-4.1$ ant -q -f httpdocs/build.xml cpparam
BUILD SUCCESSFUL
Total time: 0 seconds
In the bamboo logfile I see the following output:
24-Jul-2014 15:45:26 Starting task 'Copy the parameters dist' of type 'com.atlassian.bamboo.plugins.ant:task.builder.ant'
24-Jul-2014 15:45:26
Beginning to execute external process for build 'Deployment of 'release-7' on '*********** CI01''
... running command line:
/opt/ant-1.8/bin/ant -f /var/www/vhosts/***********/httpdocs/build.xml -q cpparam
... in: /home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865
... using extra environment variables:
JAVA_HOME=/opt/jdk-7
bamboo_planRepository_type=bb
bamboo_shortPlanName=CI Build
bamboo_planName=*********** - CI Build
bamboo_planKey=***********
bamboo_planRepository_revision=***********
bamboo_buildResultKey=***********-CB-18
bamboo_planRepository_1_revision=***********
ANT_HOME=/opt/ant-1.8
bamboo_planRepository_1_type=bb
bamboo_planRepository_1_branchName=development
bamboo_planRepository_1_name=Bitbucket
bamboo_test=test
bamboo_buildNumber=18
bamboo_planRepository_name=Bitbucket
bamboo_shortPlanKey=CB
bamboo_planRepository_branchName=development
PATH=/opt/jdk-7/bin:/opt/bamboo-elastic-agent/bin:/opt/jdk-6/bin:/opt/maven-2.1/bin:/opt/maven-1.0.2/bin:/opt/ant-1.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/bin:/bin
24-Jul-2014 15:45:26 Failing task since return code of [/opt/ant-1.8/bin/ant -f httpdocs/build.xml cpparam] was -1 while expected 0
24-Jul-2014 15:45:26 Finished task 'Copy the parameters dist'
24-Jul-2014 15:45:26 Finalising the build...
24-Jul-2014 15:45:26 Stopping timer.
Does anyone have an idea how I can fix this?
In the build plan everything works like a charm.
Thanks in advance!
EDIT:
If I run the ant command directly on the server with -verbose
-bash-4.1$ ant -f httpdocs/build.xml -verbose cpparam
Apache Ant version 1.7.1 compiled on August 24 2010
Buildfile: httpdocs/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre
Detected OS: Linux
parsing buildfile /var/www/vhosts/test/httpdocs/build.xml with URI = file:/var/www/vhosts/test/httpdocs/build.xml
Project base dir set to: /var/www/vhosts/test/httpdocs
Build sequence for target(s) `cpparam' is [cpparam]
Complete build sequence is [cpparam, cache, logs, lint, assets, clean, fixtures, dbupdate, prepare, phpunit, dlcomposer, behat, build, assetic, behat:chrome, ]
cpparam:
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
[copy] Copying 1 file to /var/www/vhosts/test/httpdocs/app/config
[copy] Copying /var/www/vhosts/test/httpdocs/app/config/parameters.yml.dist to /var/www/vhosts/test/httpdocs/app/config/parameters.yml
BUILD SUCCESSFUL
Total time: 0 seconds
The complete bamboo deployment log file with the -verbose
simple 31-Jul-2014 09:17:20 Build Deployment of 'release-7' on '**** CI01' started building on agent Elastic Agent on i-9beb61db
simple 31-Jul-2014 09:17:20 Build working directory is /home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865
simple 31-Jul-2014 09:17:20 Executing build Deployment of 'release-7' on '**** CI01'
simple 31-Jul-2014 09:17:20 Starting task 'Clean working directory task' of type 'com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:cleanWorkingDirectoryTask'
simple 31-Jul-2014 09:17:20 Cleaning working directory '/home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865'
simple 31-Jul-2014 09:17:20 Finished task 'Clean working directory task' with result: Success
simple 31-Jul-2014 09:17:20 Starting task 'Download release contents' of type 'com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:artifactdownloadertask'
simple 31-Jul-2014 09:17:20 Preparing to download plan result ****-CB-18 artifact: Shared artifact: [Symfony2 tarball], pattern: [sf2.tar.gz]
simple 31-Jul-2014 09:18:21 Artifact [Symfony2 tarball] downloaded successfully in 61s to working directory
simple 31-Jul-2014 09:18:21 Finished task 'Download release contents' with result: Success
simple 31-Jul-2014 09:18:21 Starting task 'SCP the tarball to his location' of type 'com.atlassian.bamboo.plugins.bamboo-scp-plugin:scptask'
simple 31-Jul-2014 09:18:25 Connecting to ci01.****-ops.net on port: 22
simple 31-Jul-2014 09:18:26 Uploading '/home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865/sf2.tar.gz' to '/var/www/vhosts/niko-oqt.ci01.****ci.be/releases'...
simple 31-Jul-2014 09:18:55 '/home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865/sf2.tar.gz' was uploaded successfully.
simple 31-Jul-2014 09:18:55 Finished task 'SCP the tarball to his location' with result: Success
command 31-Jul-2014 09:18:56 Substituting variable: ${bamboo.deploy.release} with release-7
simple 31-Jul-2014 09:18:56 Starting task 'Extract tarball' of type 'com.atlassian.bamboo.plugins.bamboo-scp-plugin:sshtask'
simple 31-Jul-2014 09:18:56 Connecting to ci01.****-ops.net on port: 22
simple 31-Jul-2014 09:18:56 Executing [
simple 31-Jul-2014 09:18:56 # variables
simple 31-Jul-2014 09:18:56 DIRNAME=release-7
simple 31-Jul-2014 09:18:56
simple 31-Jul-2014 09:18:56 # Create release directory
simple 31-Jul-2014 09:18:56 mkdir -p releases/$DIRNAME
simple 31-Jul-2014 09:18:56
simple 31-Jul-2014 09:18:56 # Extract that Drupal tarball.
simple 31-Jul-2014 09:18:56 tar xzf releases/sf2.tar.gz -C releases/$DIRNAME
simple 31-Jul-2014 09:18:56
simple 31-Jul-2014 09:18:56 # Remove the tarball
simple 31-Jul-2014 09:18:56 rm -f releases/sf2.tar.gz
simple 31-Jul-2014 09:18:56 ]
simple 31-Jul-2014 09:19:03 [
simple 31-Jul-2014 09:19:03 # variables
simple 31-Jul-2014 09:19:03 DIRNAME=release-7
simple 31-Jul-2014 09:19:03
simple 31-Jul-2014 09:19:03 # Create release directory
simple 31-Jul-2014 09:19:03 mkdir -p releases/$DIRNAME
simple 31-Jul-2014 09:19:03
simple 31-Jul-2014 09:19:03 # Extract that sf tarball.
simple 31-Jul-2014 09:19:03 tar xzf releases/sf2.tar.gz -C releases/$DIRNAME
simple 31-Jul-2014 09:19:03
simple 31-Jul-2014 09:19:03 # Remove the tarball
simple 31-Jul-2014 09:19:03 rm -f releases/sf2.tar.gz
simple 31-Jul-2014 09:19:03 ] has finished.
simple 31-Jul-2014 09:19:03 Result: exit code = 0
simple 31-Jul-2014 09:19:03 Finished task 'Extract tarball' with result: Success
command 31-Jul-2014 09:19:03 Substituting variable: ${bamboo.deploy.release} with release-7
simple 31-Jul-2014 09:19:03 Starting task 'Add links' of type 'com.atlassian.bamboo.plugins.bamboo-scp-plugin:sshtask'
simple 31-Jul-2014 09:19:03 Connecting to ci01.****-ops.net on port: 22
simple 31-Jul-2014 09:19:04 Executing [
simple 31-Jul-2014 09:19:04 # variables
simple 31-Jul-2014 09:19:04 DIRNAME=release-7
simple 31-Jul-2014 09:19:04
simple 31-Jul-2014 09:19:04 # remove the current http root link
simple 31-Jul-2014 09:19:04 rm -f httpdocs
simple 31-Jul-2014 09:19:04
simple 31-Jul-2014 09:19:04 # Link the release to the http root.
simple 31-Jul-2014 09:19:04 ln -s releases/$DIRNAME/www httpdocs
simple 31-Jul-2014 09:19:04 ]
simple 31-Jul-2014 09:19:04 [
simple 31-Jul-2014 09:19:04 # variables
simple 31-Jul-2014 09:19:04 DIRNAME=release-7
simple 31-Jul-2014 09:19:04
simple 31-Jul-2014 09:19:04 # remove the current http root link
simple 31-Jul-2014 09:19:04 rm -f httpdocs
simple 31-Jul-2014 09:19:04
simple 31-Jul-2014 09:19:04 # Link the release to the http root.
simple 31-Jul-2014 09:19:04 ln -s releases/$DIRNAME/www httpdocs
simple 31-Jul-2014 09:19:04
simple 31-Jul-2014 09:19:04 ] has finished.
simple 31-Jul-2014 09:19:04 Result: exit code = 0
simple 31-Jul-2014 09:19:04 Finished task 'Add links' with result: Success
simple 31-Jul-2014 09:19:04 Starting task 'Copy the parameters dist' of type 'com.atlassian.bamboo.plugins.ant:task.builder.ant'
command 31-Jul-2014 09:19:05 Beginning to execute external process for build 'Deployment of 'release-7' on '**** CI01''\n ... running command line: \n/opt/ant-1.8/bin/ant -f httpdocs/build.xml -verbose cpparam\n ... in: /home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865/var/www/vhosts/niko-oqt.ci01.****ci.be\n ... using extra environment variables: \nbamboo_deploy_environment=**** CI01\nbamboo_capability_system_builder_grailsBuilder_Grails_1_3=/opt/grails-1.3\nbamboo_capability_system_jdk_JDK_1_6=/opt/jdk-6\nbamboo_capability_system_builder_grailsBuilder_Grails_1_2=/opt/grails-1.2\nbamboo_capability_system_jdk_JDK_1_7=/opt/jdk-7\nJAVA_HOME=/opt/jdk-7\nbamboo_capability_system_builder_command_Drupal_remove_development_files=/opt/****-scripts/drupal/remove_development_files.sh\nbamboo_planRepository_type=bb\nbamboo_shortPlanName=CI Build\nbamboo_planKey=****-CB\nbamboo_capability_system_builder_command_****_Bitbucket_checkout=/opt/****-scripts/bitbucket_checkout.sh\nbamboo_capability_system_jdk_JDK_1_5=/opt/jdk-5\nbamboo_capability_system_builder_command_Compass=/usr/bin/compass\nbamboo_capability_system_builder_node_Node_js_0_10=/opt/node-0.10/bin/node\nbamboo_planRepository_1_branchName=development\nbamboo_deploy_release=release-7\nbamboo_shortPlanKey=CB\nbamboo_build_working_directory=/home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865\nbamboo_capability_system_builder_mvn3_Maven_3_0=/opt/maven-3.0\nbamboo_capability_system_builder_command_Symfony2_remove_development_files=/opt/****-scripts/symfony/remove_development_files.sh\nbamboo_capability_system_builder_command_Drupal_coder_sniffer=/opt/****-scripts/drupal/php_codesniffer_drupal.sh\nbamboo_planName=Niko - OQT - CI Build\nbamboo_capability_system_builder_phpunit_PHPUnit_3_4=/usr/bin/phpunit-3.4\nbamboo_planRepository_revision=42de29f040d3066afbc1596fc4caefd69aaa5540\nbamboo_capability_system_builder_phpunit_PHPUnit_3_7=/usr/bin/phpunit-3.7\nbamboo_buildResultKey=****-CB-18\nbamboo_capability_system_git_executable=/usr/bin/git\nbamboo_capability_system_builder_mvn2_Maven_2_1=/opt/maven-2.1\nbamboo_capability_system_builder_mvn2_Maven_2_2=/opt/maven-2.2\nbamboo_test=test\nbamboo_working_directory=/home/bamboo/bamboo-agent-home/xml-data/build-dir/26050561-26148865\nbamboo_deploy_release_previous=release-7\nbamboo_capability_system_builder_mvn2_Maven_2_0=/opt/maven-2.0\nbamboo_agentWorkingDirectory=/home/bamboo/bamboo-agent-home/xml-data/build-dir\nbamboo_capability_system_builder_ant_Ant_1_8=/opt/ant-1.8\nbamboo_capability_system_builder_command_Drush=/usr/bin/drush\nbamboo_resultsUrl=https://****.atlassian.net/builds/deploy/viewDeploymentResult.action?deploymentResultId=26935324\nbamboo_deploy_rollback=false\nbamboo_planRepository_1_revision=42de29f040d3066afbc1596fc4caefd69aaa5540\nbamboo_ManualBuildTriggerReason_userName=evert.vancauwenberg\nbamboo_planRepository_1_type=bb\nbamboo_planRepository_1_name=Bitbucket\nbamboo_capability_system_hg_executable=/usr/bin/hg\nbamboo_planRepository_branchName=development\nbamboo_capability_system_builder_command_Check_for_dpm=/opt/****-scripts/drupal/check_for_dpm.sh\nbamboo_capability_system_builder_mvn2_Maven_2=/opt/maven-2.2\nbamboo_deploy_version_previous=release-7\nbamboo_agentId=26574851\nANT_HOME=/opt/ant-1.8\nbamboo_deploy_version=release-7\nbamboo_planRepository_name=Bitbucket\nbamboo_buildNumber=18\nbamboo_capability_system_builder_grailsBuilder_Grails_2_0=/opt/grails-2.0\nbamboo_capability_system_builder_grailsBuilder_Grails_2_1=/opt/grails-2.1\nbamboo_capability_system_builder_grailsBuilder_Grails_2_2=/opt/grails-2.2\nbamboo_deploy_project=Deployment for *** - OQT\nPATH=/opt/jdk-7/bin:/opt/bamboo-elastic-agent/bin:/opt/jdk-6/bin:/opt/maven-2.1/bin:/opt/maven-1.0.2/bin:/opt/ant-1.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/bin:/bin\n
simple 31-Jul-2014 09:19:05 Failing task since return code of [/opt/ant-1.8/bin/ant -f httpdocs/build.xml -verbose cpparam] was -1 while expected 0
simple 31-Jul-2014 09:19:05 Finished task 'Copy the parameters dist' with result: Failed
simple 31-Jul-2014 09:19:05 Finalising the build...
simple 31-Jul-2014 09:19:05 Stopping timer.
simple 31-Jul-2014 09:19:05 Build 26050561-26148865-26935324 completed.
simple 31-Jul-2014 09:19:05 Finished processing deployment result Deployment of 'release-7' on '**** CI01'

Related

With powershell a Gitlab-ci job passed while failure occured

My gitlab-ci.yml contains follwing Lint code
stages:
- build
build:
stage: build
script:
- exit 1
When running, the job doesn't fail!
Running with gitlab-runner 13.10.0 (54944146)
Preparing the "shell" executor
Using Shell executor...
Preparing environment
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository
Checking out b70613dd
git-lfs/2.13.2 (GitHub; windows amd64; go 1.14.13; git fc664697)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:03
$ exit 1
Cleaning up file based variables
00:03
Job succeeded
How to avoid having false successes while the job should fail.
PowerShell 5 (the Windows default PS instance) returns a false result. When using PowerShell Core, the problem no longer appears.

Self-Hosted Github Runner: start a background server process in a job and let it run after the job ends

I am trying to do the following:
In a Self-hosted runner, run a server process. Invoke it using curl. This process monitors something during the execution of the next "another job"
Run "another job" (not on Self-hosted runner)
In the Self-hosted runner, call curl again to collect statistics.
I have the following jobs in my Github Actions workflow:
start-process: # THIS JOB IS SUPPOSED TO START A SERVER IN BACKGROUND
name: Start
needs: start-runner # previous job starts the runner
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
- uses: actions/checkout#v2
- name: npm install
working-directory: ./monitor
run: npm install
- name: npm start
run: nohup npm start & # this starts the server in background
working-directory: ./monitor
- run: curl http://localhost:8080/start
- run: ps aux
anotherjob:
// perform another job...
and according to ps aux I have my server process there:
root 4746 4.8 1.2 721308 48396 ? Sl 11:20 0:00 npm
root 4757 85.8 4.9 736308 196788 ? Sl 11:20 0:04 node /actions-runner/_work/<myrepo>/<myrepo>/monitor/node_modules/.bin/ts-node src/main.ts
root 4773 0.0 0.0 124052 2924 ? S 11:20 0:00 /usr/bin/bash -e /actions-runner/_work/_temp/51a508d8-9c2c-4723-9691-3252c8d53d88.sh
But in the Actions logs logs I have then under "Complete Job":
Cleaning up orphan processes
Terminate orphan process: pid (4731) (npm)
Terminate orphan process: pid (4742) (node)
So when I have another step
statistic:
name: Output Statistics
needs:
- start-runner
- start-process
- anotherjob
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- run: ps aux
- run: curl http://localhost:8080/statistics
and this fails: ps aux has no process anymore and curl can not connect to the address.
Question: how within the first job can I launch a process that stays on the runner after the job ends?
Turns out that in order to "protect" process from cleanup, it can be run as
run: RUNNER_TRACKING_ID="" && (nohup npm start&).
This suggestion was found in this thread on GitHub.

Avoid GitHub action buffering

I have a Github repo that contains some Linux utilites.
To run test I use GitHub actions and some simple custom workflow that runs on a remote Linux server using self-hosted runner:
name: CMake
on: [push]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout#v2
- name: Build
working-directory: ${{runner.workspace}}/Utils
shell: bash
run: cmake --build . --config $BUILD_TYPE
- name: Run test
working-directory: ${{runner.workspace}}/Utils
shell: bash
run: ./testing/test.sh
The workflow is very simple - I compile the source using cmake and then run a script from the same repo to test the build. The test script is a bash script and looks as following:
#!/bin/bash
export LD_LIBRARY_PATH=/path/to/bin
cd /path/to/bin
echo -e "Starting the tests"
./run_server &
./run_tests
if [ $? -eq 0 ]; then
echo "successful"
else
echo "failed"
exit 1
fi
Here the scripts starts up an compiled application from my code (run_server) and then run the testing utility that communicates with it and prints a result.
Actually I use C printf() inside run_tests to print the output strings. If I run that on a local machine I get output like the following:
Starting the tests
test1 executed Ok
test2 executed Ok
test3 executed Ok
successful
Each test takes about 1 sec. so I the application prints a line like testX executed Ok one per second.
But if it runs using Github actions the output looks a bit different (copied from the Github actions console):
./testing/test.sh
shell: /bin/bash --noprofile --norc -e -o pipefail {0}
env:
BUILD_TYPE: Release
Starting the tests
successful
And even in this case the output from the bash script printed out only after the script has finished.
So I have 2 problems:
no printf() output from the test application
the script output (printed using echo) come only after the script has finished
I expected the same behavior from the Github action as I get on a local machine i.e. I see a lines printed ~ 1/sec. immediately.
It looks like Github action buffers all the output until a step executed and ignores all the print from the application that run inside the bash script.
Is there a way to get all the output in real time while a step executes?

Continue build after script fails in Azure DevOps

In my Azure DevOps build task I run a Cypress test. If the test fails the build is canceled. But I want to run another task after Cypress the publishes the test results.
I've tried it with this task in my pipeline.yml file:
- task: PowerShell#2
inputs:
targetType: "inline"
script: "yarn test:cypress"
errorActionPreference: "continue"
displayName: "start server and run cypress"
But this doesn't seem to have any effect.
I've tried add -ErrorAction 'Continue' to to script"
"start": "npm-run-all -s build:shared-web run:shell",
"cy:run": "cypress run -ErrorAction 'Continue'",
"test:cypress": "start-server-and-test start http://localhost:3000 cy:run"
But this fails with:
error: unknown option: -E
It looks like Cypress is seeing the ErrorAction as a Cypress parameter.
So what's the correct way of continuing a build if a task fails?
You can add to the task this:
continueOnError: true
Now the build will keep running even the tests will fail.
If you want to fail the build if the tests failed but you want to run only one task to publish the results, you can add this to the publish tests task:
condition: always()
Now the publish task will be running always, even the tests are failed and the build canceled/failed.

How do I import registry settings using TeamCity?

I'm having trouble importing settings from a .reg file using TeamCity. The app in question has a lot of registry settings which change fairly regulary so it is vital to have it as a build step.
I'm using the following command:
regedit /s "C:\app\params\epm\epm_tlp\trunk\csr_vsm_tlp_exl.reg"
The path is fine (I checked several times). When I run this command manually, it works. However, when run from TeamCity, it doesn't seem to do anything. Here's the log:
[16:01:13]: Checking for changes
[16:01:16]: Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[16:01:16]: Checkout directory: C:\app
[16:01:16]: Updating sources: server side checkout... (1s)
[16:01:16]: [Updating sources: server side checkout...] Building incremental patch for VCS root: NEP-content
[16:01:18]: [Updating sources: server side checkout...] Repository sources transferred
[16:01:18]: Step 1/2
[16:01:18]: [Step 1/2] Using runner: simpleRunner
[16:01:18]: [Step 1/2] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script1107617910631593889.cmd
[16:01:18]: [Step 1/2] in directory: C:\app\params\epm\epm_tlp\trunk
[16:01:18]: [Step 1/2] C:\app\params\epm\epm_tlp\trunk>regedit /s "C:\app\params\epm\epm_tlp\trunk\csr_vsm_tlp_exl.reg"
[16:01:18]: [Step 1/2] Process exited with code 0
[16:01:18]: Step 2/2
[16:01:18]: [Step 2/2] Using runner: simpleRunner
[16:01:18]: [Step 2/2] Starting: c:\app\exe\startup.exe
[16:01:18]: [Step 2/2] in directory: C:\app\exe
[16:01:18]: [Step 2/2] Process exited with code -1073741515
[16:01:18]: [Step 2/2] Step failed
[16:01:18]: Publishing artifacts
[16:01:18]: [Publishing artifacts] Paths to publish: [teamcity-info.xml]
[16:01:18]: [Publishing artifacts] Sending files
[16:01:18]: Build finished
This is the first time I'm trying out TeamCity, so I have no idea where to start looking for trouble, why would this command fail? Could there be any security causes? Are TeamCity runners running as another user?
Most likely, you have TeamCity build agent running as a Windows service. Please make sure this windows service is run under windows account, which has sufficient privileges.