diff --git a/README.md b/README.md index 4ae8dbce560c732d2ca106d07a13e0bf43b73a75..4164a390d713d766358f5379d726add627b06f39 100644 --- a/README.md +++ b/README.md @@ -25,19 +25,24 @@ in a docker container. The local ``swh-jenkins-jobs`` repository will be mounted volume and cloned by Jenkins so do not forget to commit the changes you want to test. - Launch jenkins + +Executing the following script located in the root directory of that repository will automatically configure the docker image build and start the compose session. ``` -docker-compose build -docker-compose up +./start-docker-jenkins.sh ``` -Connect to localhost:8080, then within the jenkins ui: +Jenkins jobs for Software Heritage should be automatically registered when the jenkins service is starting. + +If the jobs did not get automatically registered, you can trigger their creation by following these instructions: + +- Connect to localhost:8080, then within the jenkins ui: - Create a jenkins folder `jenkins-tools` -- Create a new `free-style` job named `job-builder` inside the `jenkins-tools` targeting - this git repository `file:///opt/swh-jenkins-jobs` - - Configure the branch your are developing on (e.g. `*/master`, `*/awesome-feature`, - ...) - - Add a `build` step `Execute shell` with this content +- Create a new `free-style` job named `job-builder` inside the `jenkins-tools` +- Add a `build` step `Execute shell` with this content ``` +git config --global --add safe.directory /opt/swh-jenkins-jobs/.git +git clone file:///opt/swh-jenkins-jobs +cd swh-jenkins-jobs tox -- update --delete-old --jobs-only ``` - Save your build configuration @@ -46,32 +51,3 @@ tox -- update --delete-old --jobs-only This will install the jobs in your local jenkins. Jobs that can be run directly on the built-in node can be executed. Other jobs that may need to run docker needs the docker agent to be configured. - -# Configure a docker agent - -For making a docker agent runnable, it needs the 50000 port to be -available. - -Then, within your local jenkins, click on the local jenkins interface: - -> Manage jenkins -> Manage nodes and clouds -> New nodes - -Then fill in the form, keeping the default values and adapting the rest: - -- name: docker agent -- remote root dir: /var/tmp/jenkins -- labels: docker -- launch method: launch agent by connecting it to the controller -- custom workdir path: /var/tmp/jenkins - -Save, then click on 'docker agent' and follow the proposed instructions: - -``` -$ curl -sO http://localhost:8080/jnlpJars/agent.jar -$ mkdir -p /var/tmp/jenkins -$ java -jar agent.jar \ - -jnlpUrl http://localhost:8080/manage/computer/docker%20agent/jenkins-agent.jnlp \ - -workDir "/var/tmp/jenkins" -``` diff --git a/docker-compose.yml b/docker-compose.yml index c9161dd2dc0a033a382d0b7c25a7c5d2ed650675..f3ee60474de420de1240e64c40daa4857ed37749 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,4 @@ services: -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true ports: - 8080:8080 - # For docker agent - - 50000:50000 entrypoint: /docker/entrypoint.sh diff --git a/docker/create_swh_jobs.groovy b/docker/create_swh_jobs.groovy index 87cb1cb826728b41a023955baff4bf65f0180899..e5c0c53c34a6c7c807671ea754defa1aa2776cf2 100644 --- a/docker/create_swh_jobs.groovy +++ b/docker/create_swh_jobs.groovy @@ -12,22 +12,6 @@ def jobXml = '''<?xml version='1.1' encoding='UTF-8'?> <project> <description></description> <keepDependencies>false</keepDependencies> - <scm class="hudson.plugins.git.GitSCM" plugin="git@5.2.1"> - <configVersion>2</configVersion> - <userRemoteConfigs> - <hudson.plugins.git.UserRemoteConfig> - <url>file:///opt/swh-jenkins-jobs</url> - </hudson.plugins.git.UserRemoteConfig> - </userRemoteConfigs> - <branches> - <hudson.plugins.git.BranchSpec> - <name>*/master</name> - </hudson.plugins.git.BranchSpec> - </branches> - <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> - <submoduleCfg class="empty-list"/> - <extensions/> - </scm> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> @@ -36,7 +20,12 @@ def jobXml = '''<?xml version='1.1' encoding='UTF-8'?> <concurrentBuild>false</concurrentBuild> <builders> <hudson.tasks.Shell> - <command>tox -- update --delete-old --jobs-only</command> + <command> + git config --global --add safe.directory /opt/swh-jenkins-jobs/.git + git clone file:///opt/swh-jenkins-jobs + cd swh-jenkins-jobs + tox -- update --delete-old --jobs-only + </command> <configuredLocalRules/> </hudson.tasks.Shell> </builders> diff --git a/jobs/templates/swh-environment.groovy.j2 b/jobs/templates/swh-environment.groovy.j2 index 097b68fca699cb97a49b1f605ad0b2be7a81e0bc..eeabff55e027021d61fc3eee165c6bb102a55ed5 100644 --- a/jobs/templates/swh-environment.groovy.j2 +++ b/jobs/templates/swh-environment.groovy.j2 @@ -49,11 +49,7 @@ pipeline { pip install --upgrade pip # install dependencies ./bin/install - (cd swh-graph && - prepare-cargo-cache && - RUSTC_WRAPPER=sccache CARGO_INCREMENTAL=0 cargo build --all-features --locked) - (cd swh-provenance && - RUSTC_WRAPPER=sccache CARGO_INCREMENTAL=0 cargo build --all-features --locked) + prepare-cargo-cache (cd swh-web && yarn install) # execute tests in each swh module pip install pytest-xdist @@ -61,6 +57,10 @@ pipeline { swh_env_dir=$PWD for module in $(./bin/ls-py-modules); do cd $swh_env_dir/$module + if [ -f Cargo.toml ]; then + # build rust binaries + RUSTC_WRAPPER=sccache CARGO_INCREMENTAL=0 cargo build --all-features --locked + fi echo Executing $module checks and tests tests_dir=$(echo $module | sed 's/-/\\//g')/tests if [ -d "$tests_dir" ]; then diff --git a/start-docker-jenkins.sh b/start-docker-jenkins.sh new file mode 100755 index 0000000000000000000000000000000000000000..8bde6e7fa99cb1edaaa79102d8f6c23c8bb22eb4 --- /dev/null +++ b/start-docker-jenkins.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +docker_gid=$(stat -c '%g' /var/run/docker.sock) +docker compose build --build-arg DOCKER_GROUP=$docker_gid +docker compose up -d