Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding binscripts
Jim Van Fleet committed Jul 29, 2016
1 parent 2a2bdab commit 95e30b6
Showing 4 changed files with 104 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
bin/build.sh
bin/destroy.sh
bin/install.sh
bin/rebuild.sh
bin/rerun.sh
bin/run.sh
bin/test.sh
41 changes: 41 additions & 0 deletions BINSCRIPTS.md
@@ -0,0 +1,41 @@
# util

This repository is intended to be downloaded into a container repository during development for convenience purposes. Since the major mechanisms of developing to the Docker container construction lifecycle are identical across container images, this repository allows for consistency and additional ease of use across all container images.

## Install

If you are reading this file in BINSCRIPTS.md, your container project is likely to be util-enabled.

To use these scripts yourself, issue this command:

```
curl "https://github.internet2.edu/raw/docker/util/master/bin/install.sh?token=AAAAEddkrL9MeeA6VWcNn_PgV30r4lD1ks5XogeiwA%3D%3D" | bash
```

### common.bash

The installation process will create a common.bash file. This file should be the central, canonical authority for management of environment variables. While a subprocess may override them, the files in common.bash should be treated as authoritative defaults. Processes (e.g. `docker build`, `bats`, inside `Jenkinsfile`) can read this file and process the results therein.

You should edit this file to change the image name, and add any other helpful environment variables.

### Jenkinsfile

This will also install a Jenkinsfile to your repository, if it doesn't have one. This will ensure that your Jenkins pipeline can leverage these scripts in the way intended. Ensuring the commands that you issue on your laptop match the commands issued by the build pipeline is critical to ensure predictable, reliable results.

## Use


### Building

#### build.sh
`bin/build.sh `
#### destroy.sh
#### rebuild.sh

### Running
### rerun.sh
### run.sh


### Testing
#### test.sh
54 changes: 54 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,54 @@
node {

stage 'Checkout'

checkout scm

stage 'Acquire util'

sh 'mkdir -p bin'
dir('bin'){
git([ url: "https://github.internet2.edu/docker/util.git",
credentialsId: "jenkins-github-access-token" ])
sh 'ls'
sh 'mv bin/* .'
}

stage 'Build'

def maintainer = maintainer()
def imagename = imagename()
def tag = env.BRANCH_NAME
if(!imagename){
echo "You must define an imagename in common.bash"
currentBuild.result = 'FAILURE'
}
if(maintainer){
echo "Building ${maintainer}:${tag} for ${maintainer}"
}

sh 'bin/build.sh'

stage 'Tests'

sh 'bin/test.sh'

stage 'Push'

docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") {
def baseImg = docker.build("$maintainer/$imagename")
baseImg.push("$tag")
}


}

def maintainer() {
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
matcher ? matcher[0][1] : 'tier'
}

def imagename() {
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
matcher ? matcher[0][1] : null
}
2 changes: 2 additions & 0 deletions common.bash
@@ -0,0 +1,2 @@
maintainer="tier"
imagename="imagename-replaceme-in-common-bash"

0 comments on commit 95e30b6

Please sign in to comment.