jenkins-x / jx

Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
https://jenkins-x.io/
Apache License 2.0
4.58k stars 788 forks source link

jx step create task looks for jx-release-version, which is not found #3317

Closed kshultzCB closed 5 years ago

kshultzCB commented 5 years ago

Summary

After successfully creating a golang-http quickstart, I change directories into that directory. When I issue jx step create task , the command fails. It appears to be looking for environment variables with -s in their names, which aren't legal in bash.

Steps to reproduce the behavior

  1. Given a working JX, create a quickstart. In my particular case, I did jx create quickstart --git-provider-url=https://github.my-company.com and picked the golang-http quickstart when prompted.

  2. Once complete, CD into the directory where your quickstart was created.

  3. Run jx step create task

kshultz@kshultz-Predator-G3-571:~/jx-quickstarts$ l
total 24K
drwxr-xr-x  3 kshultz kshultz 4.0K Mar  7 14:17 .
drwx------ 55 kshultz kshultz  16K Mar  8 11:10 ..
drwxr-xr-x  5 kshultz kshultz 4.0K Mar  7 15:06 karl-golang-quickstart-for-bdd
kshultz@kshultz-Predator-G3-571:~/jx-quickstarts$ cd karl-golang-quickstart-for-bdd/
✔ ~/jx-quickstarts/karl-golang-quickstart-for-bdd [master|…1] 
11:15 $ l
total 200K
drwxr-xr-x 5 kshultz kshultz 4.0K Mar  7 15:06 .
drwxr-xr-x 3 kshultz kshultz 4.0K Mar  7 14:17 ..
drwxr-xr-x 2 kshultz kshultz 4.0K Mar  7 15:06 bin
drwxr-xr-x 4 kshultz kshultz 4.0K Mar  7 14:09 charts
-rwxr-xr-x 1 kshultz kshultz  122 Mar  7 14:09 curlloop.sh
-rw-r--r-- 1 kshultz kshultz   80 Mar  7 14:09 Dockerfile
-rw-r--r-- 1 kshultz kshultz  217 Mar  7 14:09 .dockerignore
drwxr-xr-x 8 kshultz kshultz 4.0K Mar  7 14:29 .git
-rw-r--r-- 1 kshultz kshultz   27 Mar  7 14:09 .gitattributes
-rw-r--r-- 1 kshultz kshultz   65 Mar  7 14:09 .gitignore
-rw-r--r-- 1 kshultz kshultz  398 Mar  7 14:09 .helmignore
-rwxr----- 1 kshultz kshultz   14 Mar  7 14:09 jenkins-x.yml
-rw-r--r-- 1 kshultz kshultz  405 Mar  7 14:09 main.go
-rw-r--r-- 1 kshultz kshultz 1.7K Mar  7 14:09 Makefile
-rw-r--r-- 1 kshultz kshultz   36 Mar  7 14:09 OWNERS
-rw-r--r-- 1 kshultz kshultz   62 Mar  7 14:09 OWNERS_ALIASES
-rw-r--r-- 1 kshultz kshultz   25 Mar  7 14:09 README.md
-rw-r--r-- 1 kshultz kshultz  791 Mar  7 14:09 skaffold.yaml
-rw-r--r-- 1 kshultz kshultz    1 Mar  8 11:15 VERSION
-rwxr-xr-x 1 kshultz kshultz   89 Mar  7 14:09 watch.sh
✔ ~/jx-quickstarts/karl-golang-quickstart-for-bdd [master|…1] 
11:15 $ jx step create task
running command: echo \$(jx-release-version) > VERSION
/bin/sh: 1: jx-release-version: not found

running command: jx step tag --version \$(cat VERSION)
Error: flag needs an argument: --version

Examples:
  jx step tag --version 1.0.0
Options:
  -d, --charts-dir='': the directory of the chart to update the version
  -r, --charts-value-repository='': the fully qualified image name without the version tag. e.g. 'dockerregistry/myorg/myapp'
  -v, --version='': version number for the tag [required]
      --version-file='VERSION': The file name used to load the version number from if no '--version' option is specified
Usage:
  jx step tag [flags] [options]
Use "jx options" for a list of global command-line options (applies to all commands).

error: failed to set the version on release pipelines: failed to run '/bin/sh -c jx step tag --version $(cat VERSION)' command in directory '/home/kshultz/jx-quickstarts/karl-golang-quickstart-for-bdd', output: ''
✘-1 ~/jx-quickstarts/karl-golang-quickstart-for-bdd [master|…1] 

Expected behavior

  1. The jx step create task command should proceed as expected, triggering a new pipeline run.

  2. If there's something wrong with running jx step create task at this point in time, a useful explanation should be provided as to why.

Actual behavior

  1. The pipeline does not get run.

  2. The error messages describe variables and commands which are not what the user just ran. For example, Getting an error back about jx step tag having a problem, when the command I actually ran was jx step create task, is a confusing experience.

  3. The script appears to be looking for an environment variable, named jx-release-version, which is not found:

    11:15 $ jx step create task
    running command: echo \$(jx-release-version) > VERSION
    /bin/sh: 1: jx-release-version: not found

    And that variable is unlikely to be settable anyway, because bash doesn't like environment variables with - characters in their names. Even setting this manually fails:

    ✔ ~/jx-quickstarts/karl-golang-quickstart-for-bdd [master|…1] 
    11:22 $ jx version
    NAME               VERSION
    jx                 1.3.964-dev+cac4d3141
    jenkins x platform 0.0.3513
    Kubernetes cluster v1.11.7-gke.4
    kubectl            v1.13.3
    helm client        v2.13.0+g79d0794
    helm server        v2.13.0+g79d0794
    git                git version 2.19.1
    Operating System   Ubuntu 18.10
    ✔ ~/jx-quickstarts/karl-golang-quickstart-for-bdd [master|…1] 
    11:22 $ export jx-release-version=1.3.964
    bash: export: `jx-release-version=1.3.964': not a valid identifier
    ✘-1 ~/jx-quickstarts/karl-golang-quickstart-for-bdd [master|…1] 

Jx version

The output of jx version is:

NAME               VERSION
jx                 1.3.964-dev+cac4d3141
jenkins x platform 0.0.3513
Kubernetes cluster v1.11.7-gke.4
kubectl            v1.13.3
helm client        v2.13.0+g79d0794
helm server        v2.13.0+g79d0794
git                git version 2.19.1
Operating System   Ubuntu 18.10

Jenkins type

Kubernetes cluster

GKE, set up using jx create cluster gke --tekton

Operating system / Environment

abayer commented 5 years ago

You've got to install https://github.com/jenkins-x/jx-release-version (i.e., go get -u github.com/jenkins-x/jx-release-version) to make this work. Though I recommend running that from somewhere not in a repo, 'cos it can mess up go.mod, I think?

kshultzCB commented 5 years ago

All fixed up now. Thanks @abayer .

Is that new? It might not be. Liam and I were looking at my environment and there was some pretty oddball stuff going on.