@@ -45,3 +45,58 @@ folder('Projects') {
4545 displayName(name)
4646 description(' Available projects in whanos' )
4747}
48+
49+ freeStyleJob(' link-project' ) {
50+ displayName(' Link Project' )
51+ description(' Links a repository to the Whanos infrastructure by creating a corresponding Jenkins project job.' )
52+
53+ parameters {
54+ stringParam(' PROJECT_NAME' , ' ' , ' Name of the project (e.g. my-app)' )
55+ stringParam(' GIT_URL' , ' ' , ' Git repository URL to link' )
56+ stringParam(' GIT_BRANCH' , ' main' , ' Branch to monitor (default: main)' )
57+ stringParam(' ROOT_FOLDER' , ' ' , ' Root folder in the repository (if applicable)' )
58+ credentialsParam(' GIT_CREDENTIALS_ID' ) {
59+ description(' Credentials ID for accessing the Git repository (if private)' )
60+ defaultValue(' ' )
61+ }
62+ }
63+
64+ steps {
65+ shell('''
66+ #!/bin/bash
67+ set -e
68+
69+ rm -rf repo
70+ git clone "$GIT_URL" repo
71+ cd repo
72+ git checkout "$GIT_BRANCH"
73+
74+ echo "Detecting language..."
75+ WHANOS_DIR=$PWD
76+ if [ -n "$ROOT_FOLDER" ]; then
77+ cd "$ROOT_FOLDER"
78+
79+ fi
80+
81+ LANG_DETECTED=$("$WHANOS_DIR/script/detect_language")
82+ EXIT_CODE=$?
83+
84+ if [ $EXIT_CODE -ne 0 ]; then
85+ echo "Error: repository is not Whanos-compatible"
86+ exit 1
87+ fi
88+
89+ echo "Detected language: $LANG_DETECTED"
90+ echo "$LANG_DETECTED" > $WHANOS_DIR/detected_language.txt
91+ export LANG_DETECTED=$(cat $WHANOS_DIR/detected_language.txt)
92+
93+ # Copy DSL script to workspace
94+ cp /workspace/infra/jenkins/project_job.groovy $WORKSPACE/project_job.groovy
95+ ''' )
96+ dsl {
97+ external(" project_job.groovy" )
98+ additionalClasspath(" project_job.groovy/lives" )
99+ ignoreExisting(false )
100+ }
101+ }
102+ }
0 commit comments