Skip to content

Commit 20ac075

Browse files
authored
fix: post-setup verification script update (#3921)
* fix: post-setup verification script update * docs: build-via-appstudio.sh instructions
1 parent da3b431 commit 20ac075

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

components/build-service/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ To try out a pre-configured, follow these steps.
2121
| Steps | |
2222
| ----------- | ----------- |
2323
| 1. Create project for your pipelines execution. This can be run as any non-admin user (or admin) and is needed to hold your execution pipelines. | oc new-project demo |
24-
| 2. Run build-deploy example with a quarkus app. | ./hack/build/build-via-appstudio.sh https://github.com/devfile-samples/devfile-sample-code-with-quarkus
24+
| 2. Run build-deploy example with a quarkus app. | ./hack/build/build-via-appstudio.sh https://github.com/devfile-samples/devfile-sample-code-with-quarkus src/main/docker/Dockerfile.jvm.staged
2525
| 3. View your build on the OpenShift Console under the pipelines page or view the logs via CLI. | `tkn pipelinerun logs` |
2626

2727
## Tests via RHTAP
2828

2929
To validate execution via RHTAP you can run `./hack/build/build-via-appstudio.sh` script which sets credentials and RHTAP application and components. Without parameters it creates example components.
30-
To build specific repository, pass its URL as argument as shown below:
30+
To build specific repository, pass its URL and path to repository's Dockerfile as arguments as shown below:
3131

3232
```
33-
./hack/build/build-via-appstudio.sh https://github.com/devfile-samples/devfile-sample-java-springboot-basic
33+
./hack/build/build-via-appstudio.sh https://github.com/devfile-samples/devfile-sample-java-springboot-basic docker/Dockerfile
3434
```
3535

3636
To enable PipelineAsCode integration you need to set `PIPELINESASCODE` env variable to `1` and also have to have set GitHub credentials in your `./hack/preview.env`.
@@ -40,7 +40,7 @@ Alternatively, to use GitHub webhook set `PAC_GITHUB_TOKEN` with [required permi
4040
Then run:
4141

4242
```
43-
PIPELINESASCODE=1 ./hack/build/build-via-appstudio.sh https://github.com/Michkov/devfile-sample-go-basic
43+
PIPELINESASCODE=1 ./hack/build/build-via-appstudio.sh https://github.com/Michkov/devfile-sample-go-basic docker/Dockerfile
4444
```
4545

4646
### Change of default pipeline bundle

docs/development/deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ access to all the repos you're going to create/fork into your org in the future.
184184
**Simple build:**
185185

186186
* Fork <https://github.com/devfile-samples/devfile-sample-python-basic> into your GitHub organization.
187-
* Run `hack/build/build-via-appstudio.sh https://github.com/MY_STONESOUP_ORG/devfile-sample-python-basic`
187+
* Run `hack/build/build-via-appstudio.sh https://github.com/MY_STONESOUP_ORG/devfile-sample-python-basic <path-to-repository-dockerfile>`
188188

189189
The script will create a test application and a component for you:
190190

hack/build/build-via-appstudio.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,37 @@
22
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
33

44
COMPONENT=$1
5+
PATH_TO_DOCKERFILE=$2
6+
[ -z "$MY_GITHUB_TOKEN" ] && echo "error: MY_GITHUB_TOKEN env var is not exported" && exit 1
57

68
# Configure namespace
79
$SCRIPTDIR/setup-namespace.sh
810

911
oc delete --ignore-not-found -f $SCRIPTDIR/templates/application.yaml
1012
oc create -f $SCRIPTDIR/templates/application.yaml
11-
if ! oc wait --for=condition=Created application/test-application; then
12-
echo "Application was not created sucessfully, check:"
13-
echo "oc get applications test-application -o yaml"
14-
exit 1
15-
fi
13+
14+
function create-secret {
15+
yq e "(.stringData.password=\"$MY_GITHUB_TOKEN\")" $SCRIPTDIR/templates/secret.yaml | oc apply -f-
16+
}
1617

1718
function create-component {
1819
GIT_URL=$1
20+
PATH_TO_DOCKERFILE=$2
1921
REPO=$(echo $GIT_URL | grep -o '[^/]*$')
2022
NAME=${REPO%%.git}
2123
oc delete --ignore-not-found component $NAME
2224
[ -n "$SKIP_INITIAL_CHECKS" ] && ANNOTATE_SKIP_INITIAL_CHECKS='| (.metadata.annotations.skip-initial-checks="true")'
2325
[ -n "$ENABLE_PAC" ] && ANNOTATE_PAC_PROVISION='| (.metadata.annotations."build.appstudio.openshift.io/request"="configure-pac")'
24-
yq e "(.metadata.name=\"$NAME\") | (.spec.componentName=\"$NAME\") | (.spec.source.git.url=\"$GIT_URL\") | (.spec.containerImage=\"$IMAGE\") $ANNOTATE_PAC_PROVISION $ANNOTATE_SKIP_INITIAL_CHECKS" $SCRIPTDIR/templates/component.yaml | oc apply -f-
26+
yq e "(.metadata.name=\"$NAME\") | (.spec.componentName=\"$NAME\") | (.spec.source.git.url=\"$GIT_URL\") | (.spec.source.git.dockerfileUrl=\"$PATH_TO_DOCKERFILE\") $ANNOTATE_PAC_PROVISION $ANNOTATE_SKIP_INITIAL_CHECKS" $SCRIPTDIR/templates/component.yaml | oc apply -f-
2527
}
2628

27-
echo Git Repo created:
28-
oc get application/test-application -o jsonpath='{.status.devfile}' | grep appModelRepository.url | cut -f2- -d':'
29+
create-secret
2930

3031
if [ -z "$COMPONENT" ]; then
31-
create-component https://github.com/devfile-samples/devfile-sample-java-springboot-basic
32-
create-component https://github.com/devfile-samples/devfile-sample-code-with-quarkus
33-
create-component https://github.com/devfile-samples/devfile-sample-python-basic
32+
create-component https://github.com/devfile-samples/devfile-sample-java-springboot-basic docker/Dockerfile
33+
create-component https://github.com/devfile-samples/devfile-sample-code-with-quarkus src/main/docker/Dockerfile.jvm.staged
34+
create-component https://github.com/devfile-samples/devfile-sample-python-basic docker/Dockerfile
3435
else
35-
create-component $COMPONENT
36+
create-component $COMPONENT $PATH_TO_DOCKERFILE
3637
fi
3738
echo "Run this to show running builds: tkn pr list"

hack/build/templates/component.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ spec:
99
application: test-application
1010
source:
1111
git:
12+
dockerfileUrl:
1213
url:
13-
containerImage:

hack/build/templates/secret.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: test-scm-secret
5+
labels:
6+
appstudio.redhat.com/credentials: scm
7+
appstudio.redhat.com/scm.host: github.com
8+
type: kubernetes.io/basic-auth
9+
stringData:
10+
password:

0 commit comments

Comments
 (0)