Azure Pipeline Ruby Step fails without error - azure-devops

I build a rubygem on Azure DevOps. I used that step to use RSpec:
script: bundle exec rspec spec --format RspecJunitFormatter --out test_results/TEST-rspec.xml
displayName: 'rake spec'
While execution i'm getting that issue: https://dev.azure.com/saigkill/hoe-manns/_build?definitionId=3
So it returns '1' without any error before. Maybe i have missed something?

As written there a system.debug = true helped me, to identify the problem. One of my tests failed.

Related

Azure Releases Pipeline - newman test - publish test results failed with "The following extension fields were not found: TestRunSystem"

I have a simple newman test implemented on Azure release pipeline.
The test is working, however when it try to publish the test results I got this warning:
"The following extension fields were not found: TestRunSystem"
and no tests results of course.
Any idea?

Display jest warning as a warning in the Azure DevOps pipeline build results page

We have an Azure DevOps pipeline which uses self hosted Windows agents with Azure DevOps server 2019. The pipeline runs our front-end tests. For this we use the following command line to run the tests:
npm run jest -- --ci --reporters=default --reporters=jest-junit. Then we use the publish test results task to publish the results.
This all works just fine. However, we noticed recently that the runtime warnings in the tests aren't being displayed anywhere. We have our linter warnings displayed in the build results page by adding the vso formatter like this: npm run nx run-many -- --target="lint" --all --skip-nx-cache=true --parallel --format=vso. However, it doesn't seem jest has any kind of format argument we can use.
Is it possible to take the warnings that display in the jest tests and log them in the results page of the build? Thank you for any help, please let me know if I can provide additional information.
So I ended up using the following PowerShell task to append a version of what #PerryQian-MSFT posted into my jest-setup.js file.
- task: PowerShell#2
displayName: Make test log warnings
inputs:
targetType: 'inline'
script: |
Add-Content -path config/jest-setup.js -value #"
import { command, log } from "azure-pipelines-logging";
const { error, warn } = console;
global.console.error = (...args) => {
error(...args);
log(command("task", "logissue", { type: "error" })(...args));
};
global.console.warn = (...args) => {
warn(...args);
log(command("task", "logissue", { type: "warning" })(...args));
};
"#
I had to change the solution from the GitHub post because I didn't want the tests to fail if they hit a warning, the pipeline should still succeed, just with issues. To fix this I included azure-pipelines-logging as a dependency. Then I was able to use log(command("task", "logissue", { type: "warning" })(...args)); to log in the pipeline whenever a warning is called.

Gitlab CI pipeline failing: a tag issue

My gitlab CI pipeline is setup to run maven tests from a docker image created from my maven project.
I have tested the pipeline on my master branch and it worked fine and ran the test.
However I have created a new feature branch and now running the pipeline yet again, however I now get this error
error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: getting tag for destination: repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`: it2901/cs344-maven:feature/produce-allocation-pdf
ERROR: Job failed: command terminated with exit code 1
I can't seem to pinpoint the problem at all. I have also pushed the tag: tut3 to the feature branch as well.
Here is my .gitlab-ci.yml: https://controlc.com/7a94a00f
Based on what you shared, you have this configured:
VERSIONLABELMETHOD: "tut3" # options: "","LastVersionTagInGit"
It should be either:
VERSIONLABELMETHOD: ""
or
VERSIONLABELMETHOD: "LastVersionTagInGit"
or
VERSIONLABELMETHOD: "OnlyIfThisCommitHasVersion"
When you specify "tut3", the script takes it as if it was "" (empty string). Assuming you didn't define $VERSIONLABEL anywhere $ADDITIONALTAGLIST will also be empty.
And later in the code you can see that this gets executed:
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then ADDITIONALTAGLIST="$ADDITIONALTAGLIST latest"; fi
Assuming $CI_DEFAULT_BRANCH is set to master if you use a separate branch mybranch the code above won't get executed so it's likely that the Kaniko command line doesn't have any a neither a valid $FORMATTEDTAGLIST or $IMAGE_LABELS.
You can debug by seeing their output on the script which is happening at the end before calling Kaniko:
...
echo $FORMATTEDTAGLIST
echo $IMAGE_LABELS
mkdir -p /kaniko/.docker
...
A hack would be to override $CI_DEFAULT_BRANCH with your custom branch.
✌️

Azure DevOps Databricks Pipeline Release exits with [error]Bash exited with code '1'

My Azure Devops pipeline fails withn [error]Bash exited with code '1'.
The script is a follows:
databricks workspace mkdirs /build
databricks workspace import --language PYTHON --format SOURCE --overwrite _databricks-example-repo/notebook/$(notebook_name)-$(Build.SourceVersion).py /build/$(notebook_name)-$(Build.SourceVersion).py
The full error message is a follows:
2019-10-16T10:41:42.2582015Z ========================== Starting Command Output ===========================
2019-10-16T10:41:42.2583038Z [command]"C:\Program Files\Git\bin\bash.exe" --noprofile --norc /d/a/_temp/89026089-f163-495a-92ea-285e19705127.sh
2019-10-16T10:41:42.7609581Z Error: InvalidConfigurationError: You haven't configured the CLI yet! Please configure by entering `C:\hostedtoolcache\windows\Python\3.7.4\x64\Scripts\databricks configure`
2019-10-16T10:41:43.1620919Z Error: InvalidConfigurationError: You haven't configured the CLI yet! Please configure by entering `C:\hostedtoolcache\windows\Python\3.7.4\x64\Scripts\databricks configure`
2019-10-16T10:41:43.1991465Z ##[error]Bash exited with code '1'.
2019-10-16T10:41:43.2007318Z ##[section]Finishing: Upload Notebook
Any thoughts
I have been trying to solve this for past two days. I finally realised that the problem was that I entered the wrong token ID. My advice is take nothing for granted when configuring systems .. I was 100% sure the token ID wasn't the issue, but when re-entered the token ID correctly it worked. I'm so upset with myself.
Thanks for your contributions anyway

Stop the pipeline when stage is unstable

I have a Jenkins build pipeline created using workflow plugin. At the beginning the pipeline runs a gulp build inside of the docker container and then archives test results using the following code
step([$class: 'JUnitResultArchiver', testResults: 'build/test-results/*.xml'])
In the following steps I package up the artifacts and ship them to the binary repository.
When unit tests are not passing Jenkins understands the build is unstable and marks it yellow. However it still continues with subsequent steps in the pipeline. Is there any way make the pipeline stop when unit tests are failing?
the JUnitResultArchiver will cause this condition to be true when the build is unstable:
currentBuild.result != null.
If I remember correctly it sets it to UNSTABLE, but it is enough to check that is different than null.
So you could do something like
step([$class: 'JUnitResultArchiver', testResults: 'build/test-results/*.xml'])
if (currentBuild.result == null) {
//contintue with your pipeline
} else {
//notify that the build is unstable. //or just do nothing
}
There is nothing to do at Jenkins side but at Gulp side. The call to gulp CLI needs to return a proper error value to have the sh step failing correctly.
Jenkins just interprets what the shell is returning, so you juts need to make Gulp to return a fail when tests fail (see this blog post, it seems to achieve exactly that).