Skip to content

Commit 4c87f42

Browse files
committed
remove docker build from this repo, link to new image; readme on validation
1 parent ae8d215 commit 4c87f42

15 files changed

+17
-254
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 0.3.8 - Unreleased
22

33
* switch build system to use open source openjdk-dojo image \#17574
4+
* remove docker image from this repo, use [new image](https://github.com/gocd-contrib/docker-gocd-cli-dojo) with gocd-cli
45

56
### 0.3.7 (2019-Feb-12)
67

README.md

+14-59
Original file line numberDiff line numberDiff line change
@@ -71,77 +71,32 @@ This server version also supports `format_version` of `2`. Using a newer `format
7171
Supports `format_version` value of `2`. In this version [pipeline locking](#pipeline-locking) behavior was changed.
7272

7373

74-
# Syntax checking
74+
# Validation
7575

76-
Since `0.3.2` plugin is an executable and supports basic syntax checking.
76+
There is an ongoing effort to allow in-depth validation of configuration **before pushing configuration to the source control**. This is provided by [GoCD's preflight API](https://api.gocd.org/current/#preflight-check-of-config-repo-configurations) and [gocd-cli][https://github.com/gocd-contrib/gocd-cli](https://github.com/gocd-contrib/gocd-cli).
7777

78-
## Usage with java installed
78+
You have several options to configure validation tools on your workstation:
79+
* If you have a local docker daemon, use the [gocd-cli-dojo](https://github.com/gocd-contrib/docker-gocd-cli-dojo) image. Follow the [setup instructions](https://github.com/gocd-contrib/docker-gocd-cli-dojo#setup) in the image readme.
80+
* If you don't want to use docker, you'll need to [setup `gocd-cli` on your host](https://github.com/gocd-contrib/gocd-cli).
7981

80-
You need to download the `jar` from releases page and place it somewhere convenient.
81-
For example `/usr/lib/gocd-json-plugin/json-config-plugin.jar`.
82-
Then to validate your `gopipeline.json` file run something like:
83-
```
84-
java -jar /usr/lib/gocd-json-plugin/json-config-plugin.jar syntax mypipe.gopipeline.json
85-
```
86-
87-
## Usage with `gocd` command-line helper
88-
89-
This is a product in development, so its command syntax is not stable and there are no distributed binaries yet.
90-
91-
The `gocd` tool is built in [golang](https://golang.org/) so you will need to familiarize yourself with how to set up your [go workspace](https://golang.org/doc/code.html#Workspaces).
92-
93-
Build the `gocd` binary:
82+
Either way you'll have `gocd` binary in your `PATH` or inside the docker container.
9483

95-
```bash
96-
go get github.com/gocd-contrib/gocd-cli
97-
cd ${GOPATH:-~/go}/src/github.com/gocd-contrib/gocd-cli
98-
./build.sh
99-
```
100-
101-
Follow the steps on [https://github.com/gocd-contrib/gocd-cli](https://github.com/gocd-contrib/gocd-cli) to install the plugin jar to the correct place.
102-
103-
Then:
84+
## Syntax validation
10485

86+
This will check general validity of the yaml file, without talking to the GoCD server:
10587
```bash
106-
./gocd configrepo syntax -i json.config.plugin /path/to/your-pipeline.gopipeline.json
107-
```
108-
109-
## Usage with IDE and docker
110-
111-
[IDE](https://github.com/ai-traders/ide) is a bash script, a cli wrapper around docker to help with running development tasks in docker.
112-
You can install the `ide` script so that it is available on the PATH with:
113-
```
114-
sudo bash -c "`curl -L https://raw.githubusercontent.com/ai-traders/ide/master/install.sh`"
115-
```
116-
117-
Add `Idefile` in your project with following content
118-
```
119-
IDE_DOCKER_IMAGE=tomzo/gocd-json-ide:<plugin-version>
120-
```
121-
122-
To validate files run:
123-
```
124-
ide gocd-json syntax mypipe.gopipeline.json
88+
gocd configrepo --json syntax ci.gopipeline.json
12589
```
12690

127-
Personally, I recommend the following project structure:
128-
129-
* `gocd/` directory for all your GoCD configuration files.
130-
* `gocd/Idefile` file pointing which docker image can be used to validate configuration.
91+
## Preflight validation
13192

132-
Then when working with gocd pipelines config, you can run from the root of your project
93+
This command will parse and submit your json file to the configured GoCD server.
13394
```
134-
cd gocd
135-
ide # will open interactive shell
136-
watch gocd-json syntax mypipe.gopipeline.json
95+
gocd configrepo preflight --json -r gocd-json-config-example *.gopipeline.json
13796
```
97+
Where `-r` is the configuration repository id, which you have earlier configured on GoCD server. You can check it on config repos page of your GoCD server, at `/go/admin/config_repos`. It in the upper left corner of each config repo.
98+
![config repo id](json_config_repo_id.png)
13899

139-
## Usage with docker only
140-
141-
```
142-
docker run -ti --rm --volume $(pwd):/ide/work tomzo/gocd-json-ide:<plugin-version> bash
143-
```
144-
Then you have an interactive shell as above.
145100

146101
#### Implementation note
147102

ci.gocd.yaml

+1-41
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
format_version: 3
12
pipelines:
23
"gocd-json-plugin":
34
group: gocd
@@ -19,30 +20,6 @@ pipelines:
1920
command: dojo
2021
arguments:
2122
- gradle test jar
22-
- docker:
23-
clean_workspace: true
24-
resources:
25-
- docker_builder
26-
artifacts:
27-
- build:
28-
source: "docker/imagerc*"
29-
destination:
30-
tasks:
31-
- fetch:
32-
stage: build
33-
job: build
34-
source: build/libs
35-
destination: docker
36-
- exec:
37-
command: /bin/bash
38-
arguments:
39-
- ./tasks.sh
40-
- build_docker
41-
- exec:
42-
command: /bin/bash
43-
arguments:
44-
- -c
45-
- "ops_docker_push=true ./tasks.sh build_docker"
4623
- release:
4724
approval: manual
4825
clean_workspace: true
@@ -62,23 +39,6 @@ pipelines:
6239
arguments:
6340
- ./tasks.sh
6441
- github_release
65-
dockerhub:
66-
resources:
67-
- docker_builder
68-
secure_variables:
69-
DOCKERHUB_PASSWORD: "AES:Q/TQoBrYjWDf43TbbUzSUQ==:2w9UDmYJPgEU2bmuzuehjw=="
70-
tasks:
71-
- fetch:
72-
stage: docker
73-
job: docker
74-
source: imagerc
75-
destination: docker/
76-
is_file: true
77-
- exec:
78-
command: /bin/bash
79-
arguments:
80-
- -c
81-
- ./tasks.sh publish_docker_public
8242
- bump:
8343
clean_workspace: true
8444
jobs:

docker/Dockerfile

-29
This file was deleted.

docker/bashrc

-1
This file was deleted.

docker/fix-uid-gid.sh

-39
This file was deleted.

docker/gocd-json

-3
This file was deleted.

docker/profile

-1
This file was deleted.

json_config_repo_id.png

26.4 KB
Loading

tasks.sh

+1-56
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ source .build/releaser
1010

1111
releaser_init
1212

13-
image_name_no_registry="gocd-json-ide"
14-
private_image_name="docker-registry.ai-traders.com/${image_name_no_registry}"
15-
public_image_name="tomzo/${image_name_no_registry}"
16-
image_dir="./docker"
17-
imagerc_filename="imagerc"
18-
1913
function get_version_tag {
2014
changelog_first_line=$(cat ${changelog_file} | head -1)
2115
changelog_version=$(get_last_version_from_changelog "${changelog_file}")
@@ -50,55 +44,6 @@ case "${command}" in
5044
set_version_in_changelog "${changelog_file}" "${next_version}" "false"
5145
set_version_in_file "version " "build.gradle" "${next_version}"
5246
;;
53-
build_docker)
54-
changelog_version=$(get_last_version_from_changelog "${changelog_file}")
55-
docker_build_options="--build-arg this_image_tag_arg=${changelog_version}"
56-
image_tag=$2
57-
docker_build "${image_dir}" "${imagerc_filename}" "${private_image_name}" "$image_tag"
58-
exit $?
59-
;;
60-
test_docker)
61-
source_imagerc "${image_dir}" "${imagerc_filename}"
62-
echo "Testing image: ${AIT_DOCKER_IMAGE_NAME}:${AIT_DOCKER_IMAGE_TAG}"
63-
echo "IDE_DOCKER_IMAGE=\"${AIT_DOCKER_IMAGE_NAME}:${AIT_DOCKER_IMAGE_TAG}\"" > Idefile.to_be_tested
64-
echo "IDE_WORK=$(pwd)/test/integration/test_ide_work" >> Idefile.to_be_tested
65-
time bats "$(pwd)/test/integration/end_user/bats"
66-
exit $?
67-
;;
68-
publish_docker_private)
69-
source_imagerc "${image_dir}" "${imagerc_filename}"
70-
production_image_tag=$(get_version_tag)
71-
docker_push "${AIT_DOCKER_IMAGE_NAME}" "${AIT_DOCKER_IMAGE_TAG}" "${production_image_tag}"
72-
exit $?
73-
;;
74-
publish_docker_public)
75-
source_imagerc "${image_dir}" "${imagerc_filename}"
76-
production_image_tag=$(get_version_tag)
77-
docker login --username tomzo --password ${DOCKERHUB_PASSWORD}
78-
testing_image_tag="${AIT_DOCKER_IMAGE_TAG}"
79-
80-
log_info "testing_image_tag set to: ${testing_image_tag}"
81-
log_info "production_image_tag set to: ${production_image_tag}"
82-
if ! docker images ${AIT_DOCKER_IMAGE_NAME} | awk '{print $2}' | grep ${testing_image_tag} 1>/dev/null ; then
83-
# if docker image does not exist locally, then "docker tag" will fail,
84-
# so pull it. However, do not always pull it, the image may be not pushed
85-
# and only available locally.
86-
set -x -e
87-
docker pull "${AIT_DOCKER_IMAGE_NAME}:${testing_image_tag}"
88-
fi
89-
set -x -e
90-
# When tagging a docker image using docker 1.8.3, we can use `docker tag -f`.
91-
# When using docker 1.12, there is no `-f` option, but `docker tag`
92-
# always works as if force was used.
93-
docker tag -f "${AIT_DOCKER_IMAGE_NAME}:${testing_image_tag}" "${public_image_name}:${production_image_tag}" || docker tag "${AIT_DOCKER_IMAGE_NAME}:${testing_image_tag}" "${public_image_name}:${production_image_tag}"
94-
docker tag -f "${AIT_DOCKER_IMAGE_NAME}:${testing_image_tag}" "${public_image_name}:latest" || docker tag "${AIT_DOCKER_IMAGE_NAME}:${testing_image_tag}" "${public_image_name}:latest"
95-
if [[ "${dryrun}" != "true" ]];then
96-
docker push "${public_image_name}:${production_image_tag}"
97-
docker push "${public_image_name}:latest"
98-
fi
99-
set +x +e
100-
exit $?
101-
;;
10247
github_release)
10348
if [ -z "$GITHUB_TOKEN" ]; then
10449
echo "GITHUB_TOKEN is unset";
@@ -124,7 +69,7 @@ case "${command}" in
12469
--repo gocd-json-config-plugin \
12570
--tag $VERSION \
12671
--name $VERSION \
127-
--description "$changelog_version<br>docker image tomzo/gocd-json-ide:$VERSION" \
72+
--description "$changelog_version<br>docker image kudulab/gocd-cli-dojo:json-$VERSION" \
12873
--pre-release
12974

13075
$GHRELEASE_BIN upload \

test/integration/end_user/bats/01_ide.bats

-9
This file was deleted.

test/integration/end_user/bats/02_cli.bats

-8
This file was deleted.

test/integration/end_user/bats/03_noide.bats

-8
This file was deleted.

test/integration/identities/full/.placeholder

Whitespace-only changes.

test/integration/test_ide_work/.placeholder

Whitespace-only changes.

0 commit comments

Comments
 (0)