Skip to content

Instantly share code, notes, and snippets.

View martinda's full-sized avatar
:octocat:
Coding, coding, coding.

Martin d'Anjou martinda

:octocat:
Coding, coding, coding.
  • Ottawa, Canada
View GitHub Profile
@martinda
martinda / git-merge-before-build.log
Created April 6, 2016 23:38
The jenkins console after I try to git merge before build
[Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url /tmp/jenkins/upstream-repo # timeout=10
Fetching upstream changes from /tmp/jenkins/upstream-repo
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress /tmp/jenkins/upstream-repo pull-requests/1/from
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/refs/heads/master^{commit} # timeout=10
Merging Revision 19e39345b1b178e3ebc4c5b3af277cbd64c37f9f (refs/remotes/origin/master) to origin/master, UserMergeOptions{mergeRemote='origin', mergeTarget='master', mergeStrategy='MergeCommand.Strategy', fastForwardMode='--no-ff'}
@martinda
martinda / git-merge-before-build.dsl
Created April 6, 2016 23:40
Jenkins Pipeline DSL code to demonstrate git merge before build
// Jenkins Pipeline DSL to demonstrate git merge before build
node {
String path = '/tmp/jenkins/upstream-repo'
sh "rm -rf ${path}"
ws(path) {
sh 'git --version'
sh 'git init'
sh 'touch README.md; git add README.md; git commit -m "init"'
sh 'git checkout -b pull-requests/1/from'
sh 'touch file.txt; git add file.txt; git commit -m "Add file"'
@martinda
martinda / buildFruits.gradle
Created April 22, 2016 19:00
Building fruits with Gradle
@Managed
interface FruitBinarySpec extends BinarySpec {
List<String> getFruits()
void setFruits(List<String> fruits)
}
class FruitTask extends SourceTask {
@Input
List<String> fruits
@martinda
martinda / buildFruits2.gradle
Last active June 3, 2016 13:13
Cannot access binary.args, why?
@Managed interface JuiceComponent extends GeneralComponentSpec { }
@Managed interface FruitLanguage extends LanguageSourceSet {}
@Managed
interface JuiceBinarySpec extends BinarySpec {
List<String> getArgs()
void setArgs(List<String> args)
}
class JuicerTask extends SourceTask {
$ gradle --daemon copyDeps --stacktrace
:copyDeps
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> java.lang.NullPointerException (no error message)
* Try:
@martinda
martinda / build.gradle
Last active May 5, 2016 16:02
Workaround for List<String> args not serializable
// To reproduce the bug:
// mkdir -p src/main/apple
// echo "red" >src/main/apple/pomme.txt
// gradle juicerJuicer
@Managed interface JuiceComponent extends GeneralComponentSpec { }
@Managed interface FruitLanguage extends LanguageSourceSet {}
@Managed
interface JuiceBinarySpec extends BinarySpec {
File getOutputDir()
@martinda
martinda / Dockerfile
Created January 1, 2017 17:56
Trying to figure out some best practice for running python tests
FROM python@sha256:d7728edb9e52abc58552cec26d871f474394f3ffdefbe2929da93bfa42d92b1f
# Where the project files will be installed and tested inside the container
WORKDIR /usr/local/plowapp
# Copy the project files to the WORKDIR
COPY . .
# The python version in the container is owned by the OS of the container
# We need to isolate our project from the OS requirements by installing the virtualenv
@martinda
martinda / python3.6-setup.log
Created January 22, 2017 15:24
str object has no attribute decode
Sending build context to Docker daemon 203.8 kB
Step 1/4 : FROM python:3.6
---> 775dae9b960e
Step 2/4 : WORKDIR /tmp/app
---> 0a50baeafe90
Removing intermediate container 06d9206a8888
Step 3/4 : COPY requirements.txt requirements.txt
---> b8ee42a4b0f8
Removing intermediate container 3ef5cc0e069a
Step 4/4 : RUN python -m venv /tmp/venv && . /tmp/venv/bin/activate && pip install -r requirements.txt
@martinda
martinda / symlinkFile.groovy
Created July 6, 2017 19:26
Detect Symbolic link in Jenkins
// This snippet causes a java.io.NotSerializableException: sun.nio.fs.UnixPath
// Not sure why because I use @NonCPS
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files
Path gradlePropertiesPath = Paths.get('/localdisk/jenkins/gradle/gradle.properties')
node() {
symlinkFile(gradlePropertiesPath)
@martinda
martinda / check_envvar_value_is_ok.mk
Created July 26, 2017 08:53
Check env var value is ok in Makefile
ifeq ($(VERILATOR_ROOT),)
$(error VERILATOR_ROOT is not set. Please set it.)
else
ifeq ($(wildcard $(VERILATOR_ROOT)/expected_file),)
$(error VERILATOR_ROOT is set to $(VERILATOR_ROOT) but not finding expected_file in there.)
endif
endif
all:
echo Done