Error While Running .sh file as a Part of YML file


#1

Here is the code.
java.yml code:

platform: linux

image_resource:
type: docker-image
source:
repository: openjdk
tag: 8-jdk

run:
path: C:\Users\I355480\Desktop\Java\java.sh

java.sh code:

#!/usr/bin/env sh
javac samp.java
java samp

Note: All the files are in the same folder (java.yml, java.sh, samp.java)
This is the error i’m getting (see image).


#2

Hi,

i think there is some misunderstanding here in how the Bash script comes into your task container.

path: C:\Users\I355480\Desktop\Java\java.sh

Thats the local path under which your bash script resides on your computer. But Concourse instead runs your tasks in a docker container.

For the docker container to be able to execute the script, it first needs to mount the resources that are required for this.

In the Concourse world this is done via Concourse Resources. In your case, you could e.g. put your Bash script into a Github Repo and let Concourse receive it from there using the Concourse-Git-Resource.

To see how you can work with resources and reference them in your Jobs and Tasks checkout this tutorial Pipeline-Resources.

best,
D


#3

okay then, ill upload my code into the git repo and using “get” i’ll get my repo and will execute again.
Am i correct ?


#4

Yes, you must declare the Repo Resource in your Job using the get directive and then in your task you have to define it as input.

Afterwards you will have the resource in your container under the current root directory and can execute any script that you have in your Git Repo.

This way you can execute your scripts on any system as Concourse always knows how to receive them from Github using the Git-Resource.

best,
D


#5

I’ll complete my code and i’ll post it here about the result.
Thank you so much for helping me out.


#6

@gdenn
Still i’m getting the same error.
Here is the modified code:
resources:

  • name: git-repo
    type: git
    source:
    uri: https://github.com/7thwik/Java-Concourse
    branch: master
    jobs:
  • name: run-java
    public: true
    plan:
    • get: git-repo
    • task: hello-world
      config:
      platform: linux
      image_resource:
      type: docker-image
      source:
      repository: openjdk
      tag: 8-jdk
      inputs:
      - name: git-repo
      run:
      path: ./git-repo/java.sh
      Here is the error on web-ui (image):

#7

i think it should be like this “git-repo/java.sh”.

You can also checkout your docker container which runs the task by using the fly hijack command.

best,
D


#8

Sorry, it is in the same way as you mentioned (git-repo/java.sh)
What should i do now ? How to rectify this error ?


#9

i recommend you hijack (login into the container) and check if you can find your resource:

fly -t <your concourse target> -j <pipeline-name>/<job-name>

best,
D


#10

@gdenn
This is the Output:
image


#11

@gdenn
I can see my resource name “git-repo”.


#12

@marco-m are you there ? Please look at this issue as well.


#13

inspect the hello-world task.

When you are logged into the container check with ls if you can see a folder containing your bash script.


#14

@gdenn This is Sathwik (7thwik) i have reached max no of replies on Day 1 and i can’t reply through my account, please ping me here iamsatwikkotagiri@gmail.com, so that we can continue…


#15

I suggest you use the Concourse discord then Join us in Discord!