I'm trying to find a way to create a task noTestBuild to do the following:
gradle clean build -x test
How can I create this. I saw this link which talks about creating alias tasks : https://www.mail-archive.com/user#gradle.codehaus.org/msg09173.html
Is there an easy way to do this using Gradle/Groovy code rather than using type: Exec and calling "sh" or "bash" to call "gradle clean build -x test"
I suspect you are looking for gradle assemble
If you're applying the 'java' plugin, then as previously mentioned, 'gradle clean assemble' should achieve the result you're looking for.
However, if you also want to include clean, this might do the job:
task noTestBuild(type: GradleBuild) {
tasks=[clean, assemble]
}
Related
I have an Aurelia CLI app that uses the CLI in conjunction with Gulp to build. I was asked to enable a feature where we pass the name of the branch we're building and determine an environment from that. I was hoping to do this within my gulp tasks. I think I can achieve it through our Continuous Integration, but, I'd like to do it from within gulp if possible. Is this possible?
You can pass any custom arguments to Aurelia CLI and grab them from within your build tasks.
Say you call au run --branch master
You can get the value from within a task like so:
import { CLIOptions } from "aurelia-cli";
const branch = CLIOptions.getFlagValue('branch')
Is that what you need?
We use Visual Studio Team Services for Continuous Integration. I added a Powershell Script build step to our definition, which, depending on the name of the passed branch, would write a variable with the right environment name. Then, I'm planning to add an additional build step to my definition, to only run when the master branch is being built - to rebuild my source without the testing framework.
The powershell script we use to write the variables is as follows:
if ($env:BUILD_SOURCEBRANCHNAME -eq "qa"){
Write-Output ("##vso[task.setvariable variable=auenv]" + "stage")
}
elseif ($env:BUILD_SOURCEBRANCHNAME -eq "master")
{
Write-Output ("##vso[task.setvariable variable=auenv]" + "prod")
}
else
{
Write-Output ("##vso[task.setvariable variable=auenv]" + "dev")
}
Then, when it comes time to use it:
au build --env $(auenv) --version $(Build.BuildNumber) --testable
Finally, we build without the test framework
au build --env $(auenv) --version $(Build.BuildNumber)
I recognize my solution is out of scope relative to the audience I asked it for. Sorry about that.
I am trying to use the Publish Over SSH plugin to publish many kinds of build artifact to an external server. Examples of build artifacts are compiled builds, XML output from testing, and JSON output from linting.
If testing or linting results in errors, the build will fail or be marked unstable. In the case of a failed build, the Publish Over SSH plugin will not copy the build artifacts, writing to the console:
SSH: Current build result is [FAILURE], not going to run.
I see no reason why I wouldn't want to publish this information if it exists, and I would like to continue to report errors as build failures. So, is there any way to force Jenkins to publish build artifacts even if the job is marked as a failure?
I thought I could use the Flexible Publish to force this, by wrapping the Publish Over SSH in an "always" condition, but this gave the same output as before on a build failure.
I can think of a couple of work-arounds:
a) store the build status in an environment variable; force the status to SUCCESS; perform the publish step; recover the build status from the environment variable using java jenkins-cli.jar set-build-status $STORED_STATUS
OR
b) Write a bash script to perform the publishing step manually using SSH, cutting out the Publish Over SSH plugin altogether
Before I push forward with either of these solutions (neither of which I like), is there any piece of configuration that I'm missing?
The solution I ended up using was to use rsync/ssh to copy the files manually using a post build script. I configured this in my Jenkins Job Builder YAML like so:
- publisher:
name: publish-to-archive
publishers:
- post-tasks:
- matches:
- log-text: ".*"
script: |
ssh -i ${{HOME}}/.ssh/id_rsa jenkins#archiver "mkdir -p {archive_path}"
rsync -Pravdtze "ssh -i ${{HOME}}/.ssh/id_rsa" {source_path} jenkins#archiver:{archive_path}
Quoting old hooky on jenkinsci-users:
How can I force Publish Over SSH to work even if the build has been marked
a failure?
Use "Send files or execute commands over SSH after the build runs" in
configuration section "Build environment"
Job configuration / Build Environment / Send files or execute commands over SSH after the build runs
instead of using a post-build or build-step.
How do I explicitly say with my go test command to run only tests for the main package and not others in my source directory.
At the moment it's working with $go test -v. But... I am using goconvey as well and it seems to be running recursively. According to this page https://github.com/smartystreets/goconvey/wiki/Profiles I have a file where I can pass arguments into the go test command. I know you can go test -v ./... for recursive or go test -c packagename/... but how do I just do it for the main?
Profiles is one to accomplish this, but you can also specify a 'depth' for the runner:
$ goconvey -depth=0
A value of 0 limits the runner to the working directory.
Run goconvey -help for details.
In my repo's subdirectory, I have some scripts with package main to show some example usage fo my package. But this gives me the following errors when being tested on Travis.
repo
example-dir
sub-dir
main.go // this gives me error like the following
github.com/~/directory-for-main-program
The command "go get -v ./..." failed. Retrying, 2 of 3.
I see this error only in Travis , not in local machine with go test.
Is there anyway to separate the main program and still able to pass the Travis testing?
Either use the correct path in your main.go, which is the proper way or use build constraints to disable that file:
// +build local
package main
//other code
then to locally build it use go build -tags local or go run -tags local
We have three different maven2 profiles: prod, dev and test. One should be able to build with either one of those three profiles, or without any profile. In other words, following commands are acceptable:
mvn install
mvn -Pdev install
mvn -Ptest install
mvn -Pprod install
In case someone writes for example mvn -Ppord install, the build must fail. Is this possible to do?
P.s. I'm aware of http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html but it seems that with require property it would not be possible to allow building without profile.
I think it should be possible with writing custom enforcer rule. If you'll look at this example you'll see:
RuntimeInformation rti = (RuntimeInformation) helper.getComponent( RuntimeInformation.class );
this line gives you information about current runtime, following get MavenProject and active profiles list
MavenProject project = (MavenProject) helper.evaluate( "${project}" );
List profiles = new ArrayList( project.getActiveProfiles() );
If list of active profiles will be insuficient, you can get all profiles - example of this code can be found in AllProfilesMojo.java from helper plugin.