Skip to content

Instantly share code, notes, and snippets.

@rohancme
rohancme / Jenkinsfile-windows.groovy
Last active November 3, 2017 02:06
A simple Windows Jenkinsfile for the Kubernetes plugin
podTemplate(label: 'windows-vs2017',
containers: [
containerTemplate(name: 'jnlp', image: '{{REPLACE-WITH-YOUR-CUSTOM-IMAGE}}',
envVars:[
containerEnvVar(key: 'HOME', value:'C:\\users\\containeradministrator'),
containerEnvVar(key: 'JENKINS_HOME', value: 'G:\\')
],
workingDir:'C:\\Jenkins\\')
],
nodeSelector: 'beta.kubernetes.io/os=windows') {
@rohancme
rohancme / Jenkinsfile-ubuntu.groovy
Last active November 3, 2017 02:06
Jenkinsfile for a Linux build with the K8S plugin
podTemplate(label: 'my-build-pod', containers: [
// This is the official jnlp base image with added support for ssh access to git repos
containerTemplate(name: 'jnlp', image: 'larribas/jenkins-jnlp-slave-with-ssh:1.0.0', args: '${computer.jnlpmac} ${computer.name}'),
// This image gives us a container with kubectl installed so we can deploy the image we build
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl', ttyEnabled: true, command: 'cat'),
// A docker container to build our image
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true)]) {
node ('my-build-pod') {
// Store ssh credentials in Jenkins, replace GITHUB_URL with your Github Repo
git branch: "${env.BRANCH_NAME}", credentialsId: "{{JENKINS_CREDENTIALS}}", url: '{{GITHUB_URL}}'
@rohancme
rohancme / jenkins-windows-msbuild-Dockerfile
Last active September 23, 2020 01:29
My base MSBuild image
FROM microsoft/windowsservercore
# Pass in JENKINS_SECRET and JENKINS_JNLP_URL as an environment variables
# Install jre and add to PATH
# Do not recommend pushing the image to a public repository due to Oracle's EULA: http://www.oracle.com/technetwork/java/javase/documentation/index.html
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN wget 'http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185' -Outfile 'C:\jreinstaller.exe' ; \
Start-Process -filepath C:\jreinstaller.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91" ; \
FROM microsoft/windowsservercore
# Specify a public IP here so the build machine can download slave.jar
ARG BASE_URL
# Specify the internal Kubernetes service IP Address here
ARG JENKINS_JNLP_URL
ARG JENKINS_SECRET
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
@rohancme
rohancme / jenkins-ubuntu-agent-Dockerfile
Last active November 3, 2017 02:07
Jenkins Ubuntu slave
FROM jenkinsci/jnlp-slave
ENV JENKINS_AGENT_NAME ubuntu-agent
## Location to download slave.jar from
ARG JENKINS_URL
ARG JENKINS_SECRET
@rohancme
rohancme / jenkins-master-deployment.yaml
Created July 15, 2017 01:37
Jenkins master Kubernetes deployment file
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: jenkins-master
namespace: ci
spec:
template:
metadata:
labels:
name: jenkins-master
@nl5887
nl5887 / transfer.fish
Last active March 22, 2022 09:07
Bash and zsh alias for transfer.sh. Transfers files and directories to transfer.sh.
function transfer
if test (count $argv) -eq 0
echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
end
## get temporarily filename, output is written to this file show progress can be showed
set tmpfile ( mktemp -t transferXXX )
## upload stdin or file
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@takluyver
takluyver / README.md
Created September 6, 2014 21:44
Flatten notebooks for git diff

Copy nbflatten.py to somewhere on $PATH. Then, in the root of a git repository, run these commands:

echo "*.ipynb diff=ipynb" >> .gitattributes 
git config diff.ipynb.textconv nbflatten.py

When you change a notebook and run git diff, you'll see the diff of flattened, simplified notebooks, rather than the full JSON. This does lose some information (metadata, non-text output), but it makes it easier to see simple changes in the notebook.

This doesn't help with merging conflicting changes in notebooks. For that, see nbdiff.org.